# Dynamic Navigation Node

We can define a dynamic `NavigationKey` that renders a different navigation node based on the current screen width for example. Even if we change the navigation node from a `Dialog` to a `BottomSheet` we can persist the same `ViewModel` and `SavedStateRegistry`. To share some UI State between the two types, make sure to add a `key` to your `rememberSaveable` call, since they are rendered in different containers, they have different `compositionKeyHash` which is used to automatically key the `rememberSaveable` calls.

```kotlin
val navigator = rememberNavigator { 
    if (screenWidth <= 600) {
        dialog<DynamicKey> { DynamicContent() }
    } else {
        bottomSheet<DynamicKey> { DynamicContent() }
    }
}

@Composable
fun DynamicContent() {
    // This saveable text will be persistent even if we change from a dialog to a bottomsheet!
    val someText = rememberSaveable(key = "text-key") { mutableStateOf("Text") }
}
```


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://roudi.gitbook.io/guia-navigation/using-guia/the-lore/navigator-config/dynamic-navigation-node.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
