Navigation 3
Overview
Implement state-driven navigation in Jetpack Compose using Navigation 3. Unlike Navigation Compose, Navigation 3 models navigation as application state rather than through a NavController. This skill covers navigation keys, back stack management, ViewModel scoping, entry decorators, adaptive layouts, deep links, animations, state restoration, and testing.
Setup
Add the Navigation 3 dependencies:
Core Concepts
1. Define Navigation Keys
Navigation destinations are represented by immutable serializable objects.
Keys become your navigation state.
2. Create the Back Stack
Navigation 3 replaces NavController with a mutable state back stack.
3. Create NavDisplay
Navigation Patterns
Navigate Forward
Navigate Back
Replace Current Screen
Clear Back Stack
Pop To Root
Argument Handling
Retrieve Arguments
Arguments already exist inside the navigation key.
Pass IDs, Not Objects
ViewModel Integration
Navigation 3 scopes ViewModels using entry decorators.
ViewModel Example
Entry Decorators
Navigation 3 uses decorators to attach lifecycle functionality.
Scene Setup
Creates the navigation scene for each entry.
Saved State
Automatically restores destination state after process recreation.
ViewModel Store
Scopes ViewModels to each navigation entry.
Adaptive Navigation
Navigation 3 integrates with Material Adaptive layouts.
Use adaptive scene strategies to automatically switch between:
- Single pane (phones)
- Two pane (tablets)
- Foldables
Deep Links
Deep links should resolve into navigation keys.
Avoid manually constructing route strings.
Animations
Navigation transitions are defined using scene transitions.
Navigation 3 animation APIs may evolve while in alpha.
State Restoration
Navigation keys are serializable and automatically restored.
Always ensure keys are serializable.
Testing
Navigation becomes simple because it is state-driven.
Example
Compose UI tests can verify screen rendering by inspecting the current back stack.
Migration from Navigation Compose
Recommended Project Structure
Critical Rules
DO
- Use immutable serializable keys
- Keep navigation state inside Compose
- Pass IDs instead of complex objects
- Scope ViewModels using entry decorators
- Use
rememberSaveablefor state restoration - Model navigation as observable application state
DON'T
- Use string routes
- Pass repositories or ViewModels through navigation
- Mutate navigation keys
- Store business objects in the back stack
- Recreate the back stack on recomposition
- Mix Navigation Compose APIs with Navigation 3 APIs
References
- Android Navigation 3 documentation
- Navigation 3 samples
- Lifecycle ViewModel Navigation 3 documentation
- Material 3 Adaptive Navigation documentation


