Recipes

The recipes app contains runnable examples. Each recipe shows one concept. The recipe source is in the recipes directory of the repository.

Where a recipe matches a recipe in Google’s Navigation 3 recipes, the “Navigation 3 recipe” column names the Navigation 3 recipe.

Run the recipes app

Clone the repository, then run one of these commands from the repository root:

Platform Command
Desktop ./gradlew :recipes:app:desktop:run
Android ./gradlew :recipes:app:android:installDebug, then open “Enro Recipes” on the device
Web ./gradlew :recipes:app:web:wasmJsBrowserDevelopmentRun
iOS Open EnroRecipes.xcodeproj in Xcode and run the project

Basic

Recipe Shows Navigation 3 recipe
Basic Navigation open, close, and keys with arguments Basic
Saveable Back Stack A backstack and rememberSaveable state that are restored after a configuration change Saveable back stack
Saved State How long state is kept by remember, rememberSaveable, a ViewModel and SavedStateHandle Saveable back stack
Destination Registration Function and provider destinations; dialog() and directOverlay() metadata Entry provider DSL
Back Stack Operations Back to root, back to a specific screen, replace the current screen, clear the stack —
Basic Deep Link @NavigationPath, hand-written path bindings, and resolving a URL to a key Uri with Arguments
Handling a Deep Link Opening a destination from a URL that the app receives from outside the app Static Uri
Advanced Deep Link A synthetic backstack for a deep link Synthetic BackStack

Scenes and overlays

Recipe Shows Navigation 3 recipe
Dialog Navigation Dialog destinations with dialog() and directOverlay() Dialog
Navigating From a Dialog Opening a screen on top of a dialog, replacing a dialog, stacking dialogs —
Bottom Sheet Navigation ModalBottomSheet as a destination BottomSheet
List-Detail (Scene) A hand-written list-detail scene strategy List-Detail Scene
Two-Pane (Scene) Two adjacent destinations side by side Two pane Scene
List-Detail (Containers) List-detail built from two containers —
Material List-Detail Material 3 Adaptive ListDetailPaneScaffold as a scene strategy Material List-Detail
Material Supporting Pane Material 3 Adaptive SupportingPaneScaffold as a scene strategy Material Supporting Pane
Nested Containers Which container opens a key passed to open; accept { } filters —
Tab Navigation One container per tab Common navigation UI
Multiple Back Stacks One backstack per tab; each backstack is kept when the user changes tab Multiple back stacks
Scene Decoration A SceneDecoratorStrategy that adds a sidebar or bottom bar Responsive Navigation Scene Decorator
Shell Scene A multi-pane app shell configured by destination metadata —

Animations

Recipe Shows Navigation 3 recipe
Animated Navigation NavigationAnimations for a container Animations
Per-Destination Transitions Transitions for one destination; the predictive back gesture Animations
Staggered Animations Animating parts of a destination on their own timing —
Shared Element Animations sharedElement across destinations —

State and results

Recipe Shows Navigation 3 recipe
Basic ViewModel A NavigationHandle inside a ViewModel Basic ViewModel
Koin ViewModel A ViewModel with dependencies from Koin and arguments from the destination’s key Koin injected ViewModel
Koin Modular Features that each provide a Koin module and open each other’s screens by key Koin modular
Metro ViewModel A ViewModel with dependencies from a Metro graph and arguments from the destination’s key Metro injected ViewModel
Metro Modular Features that contribute to one Metro graph and open each other’s screens by key Metro modular
Shared ViewModel One ViewModel used by several destinations Shared ViewModel
Sharing State with Results Passing a value to a child screen and receiving the edited value as a result —
Returning Results NavigationKey.WithResult and registerForNavigationResult Results as Events
Results in a ViewModel Requesting and receiving a result from a ViewModel —
Managed Flow A multi-step flow as a destination —
Flow in a ViewModel A multi-step flow declared in a ViewModel —
Request-Close Confirmation Confirming before a screen closes —

Advanced

Recipe Shows Navigation 3 recipe
Conditional Navigation An auth gate with an interceptor on a container Conditional navigation
Module Interceptor An interceptor for every container in the app —
Modular Navigation Feature modules that open each other’s screens without depending on each other Hilt, Koin and Metro modular
Opened Timestamp Plugin A NavigationPlugin —

Synthetic destinations

Recipe Shows Navigation 3 recipe
External URL Launcher A key that runs a side effect and shows no screen —
Auth Gate A key that redirects to a login screen Conditional navigation
Result Decider A key that forwards another destination’s result —

Interop

Recipe Shows Navigation 3 recipe
Native Interop A platform view (AndroidView, SwingPanel) inside a destination Fragment and View Interop

Platform recipes

Each platform recipe is listed only in the recipes app for that platform, under “This Platform”.

Recipe Platform Shows Navigation 3 recipe
Fragment and Activity Android A Fragment and an Activity as destinations; the Activity returns a result Fragment and View Interop
UIViewController iOS A UIViewController as a destination: embedded, presented modally, and pushed —
Multiple Windows Desktop A destination that opens in a separate window and returns a result —

Tests

RecipeSmokeTests runs the recipes on desktop with Compose UI tests. RecipeSmokeTests is also an example of a navigation test that uses the real UI: each test installs the app’s NavigationComponent, shows a container, and clicks through a recipe. Run RecipeSmokeTests with ./gradlew :recipes:common:desktopTest.


This site uses Just the Docs, a documentation theme for Jekyll.