---
name: add-compose-nav-3
description: Adds Jetpack Navigation 3 to a Compose project with typed routes, a saveable back stack, and a scene for a dialog or a wide list-detail. Use when the user wants Navigation 3, a NavDisplay, or to leave string routes behind.
license: Apache-2.0
metadata:
  category: apps
  tags: "android,jetpack-compose,navigation"
  author: johnny-bravo
  version: "1.0"
  updated: "2026-11-09"
  status: published
  aliases: "navigation-3, NavDisplay, NavKey, saveable back stack"
  source_url: "https://github.com/android/skills/tree/6daa53ef27fa2aa87827d183a85c06cedceca833/navigation/navigation-3"
  source_license: Apache-2.0
  copyright: "Copyright line in upstream LICENSE.txt is the unfilled Apache template 'Copyright [yyyy] [name of copyright owner]'. Skill metadata.author at this commit is Google LLC. No NOTICE file in the repository."
  original_author: "Google LLC (android/skills, navigation/navigation-3)"
  modified: "Modified by TheSkillVault on 2026-11-09: rewritten as a short Navigation 3 starter (typed keys, NavDisplay, saveable stack, per-section stacks, scenes, results); dropped the recipe index, Hilt and Koin catalogues, and animation recipes. Not the original file and not official Android documentation."
  imported_on: "2026-11-09"
---

# Add Compose Navigation 3

Navigation 3 uses a typed route per destination and a back stack you can save. String routes and a second graph for every dialog are the old shape.

## When to use
- The Compose project still moves between screens with string routes.
- Each bottom destination should remember its own stack.
- A dialog, a deep link, or a signed-out flow needs a real destination.

## When not to use
- Skip this when you are choosing a tab row or a rail. That choice is a separate skill.
- Skip this when you are deciding columns or when a list sits beside a detail. That width choice is a separate skill. This skill only hosts the scene.
- The project is React Native or SwiftUI. Do not rewrite it for this.

## Steps
1. Show destinations in a NavDisplay. Give each destination a typed route. Do not pass a raw string as the route.
2. Store the back stack in a saveable holder so a rotation or process death does not forget the screen.
3. Give each top-level destination its own stack. Switching destinations restores that stack instead of clearing it.
4. A dialog or a sheet is a scene on the same stack. A list beside a detail on a wide screen is also a scene. Let the layout skill decide when the width counts as wide.
5. Read arguments from the route when building a ViewModel. Send a result back to the previous entry as state or as an event.
6. Keep a signed-out flow and a signed-in flow as separate graphs. Switch graphs when the condition changes, and do not leave a signed-in screen up after sign-out.

## Gotchas
- Do not include passwords, tokens, or private ids in sample routes or deep-link examples.
- Mixing string routes with typed routes in the same stack makes the back stack lie. A migration error is leaving both in the graph.
- A deep link should rebuild the stack beneath the opened screen, or Back dumps the person out of the product.
- This is an independent how-to adapted from a Google LLC skill. It is not official Android documentation, and it was not run on a device for this library.

## Portability
If you use Navigation 2, move that graph's routes to typed routes rather than running both stacks at once. If you use React Native, keep the React Navigation stack. A stack per destination still applies.

## Done when
- Destinations are typed routes shown in a NavDisplay.
- Each top-level destination keeps its own saveable stack.
- A dialog is a scene, and a deep link rebuilds the stack beneath it.

## Example prompt
"Migrate this Compose graph off string routes onto Navigation 3. Use a NavDisplay, a saveable back stack, and a separate stack for each bottom destination."

---
Adapted from "navigation-3" by Google LLC in android/skills (Apache-2.0). The upstream licence leaves the copyright line unfilled. See LICENSE.txt and NOTICE.txt.
