Back to Swift Reference Ask BeeAI
📱 SwiftUIBeginneriOS 16+
NavigationStack & navigationDestination
Data-driven, type-safe navigation that supports deep links and programmatic push/pop.
NavigationStack replaces NavigationView. Push values with NavigationLink(value:) and map value types to screens with .navigationDestination(for:).
Bind the stack to a path array to push, pop or reset navigation from code.
navigationstack.swift
1struct Recipe: Hashable, Identifiable {
2 let id = UUID()
3 let name: String
4}
5
6struct RecipesView: View {
7 @State private var path: [Recipe] = []
8 let recipes = [Recipe(name: "Pancakes"), Recipe(name: "Kabsa")]
9
10 var body: some View {
11 NavigationStack(path: $path) {
12 List(recipes) { recipe in
13 NavigationLink(recipe.name, value: recipe)
14 }
15 .navigationTitle("Recipes")
16 .navigationDestination(for: Recipe.self) { recipe in
17 Text(recipe.name).font(.largeTitle)
18 }
19 .toolbar {
20 Button("Pop to root") { path.removeAll() }
21 }
22 }
23 }
24}Common pitfalls
- Place .navigationDestination inside the NavigationStack, not on a lazy container child that may not be loaded.
Still unclear? Ask BeeAI about NavigationStack & navigationDestination.
Get a tailored explanation, or paste your own code for a Swift 6 review. Free members get daily questions — Pro is unlimited.
Related topics
Become a Founding Pro member: unlimited BeeAI, upcoming Swift paths and every new reference entry first.
See Pro Plans