Guia Navigation
Github
  • Overview
  • Setup
  • Using Guia
    • 📔Express Lore
      • Quick Start
    • 📖The Lore
      • Navigation Key
      • Navigation Node
        • Screen
        • Bottom Sheet
        • Dialog
      • Navigator
        • Navigation Operations
        • Navigator Instance
        • Back Handling
      • Navigator Config
        • Dynamic Navigation Node
        • Transitions
      • Containers
      • NavHost
        • Back Handling
      • Multi module navigation
        • NavHost Multi module
      • Deep Linking / Global Navigation
      • Results
      • Lifecycle, ViewModel, Saved State
      • UI Tests
  • 🤖Advanced
    • Custom LifecycleManager
Powered by GitBook
On this page
  1. Using Guia
  2. The Lore
  3. Navigator

Navigator Instance

PreviousNavigation OperationsNextBack Handling

Last updated 2 years ago

provides the navigator it's using to all its children using Composition Locals.

We can use the below to get the current navigator inside a Composable.

@Composable
fun HomeScreen() { 
    // Returns an optional navgiator
    val navigator = localNavigator() 

    // Returns a none-null navigator, throws an exception if one isn't provided.
    val navigator = requireLocalNavigator()
}

For instances where we are nesting a navigator inside another navigator's NavContainer and we want the direct parent we can use:

@Compoasble
fun HomeScreen() {
    // Returns an optional navgiator
    val parentNavigator = localParentNavigator()
    
    // Returns a none-null navigator, throws an exception if one isn't provided.
    val parentNavigator = requireLocalParentNavigator()
}

Make sure to hoist the navigation operations to another Composable. To make previews easier.

📖
NavContainer