MasterOnce
HomeBlogHow-To
3 min readMar 14, 2026
Swift

How to Use NavigationStack

Build navigation using the modern API.

Steps

  1. Paste the view into a SwiftUI file.
  2. Set it as a preview or root view.
  3. Update state or bindings to match your data.

Copy and paste

import SwiftUI

struct HomeView: View {
    var body: some View {
        NavigationStack {
            List {
                NavigationLink("Details", value: "details")
            }
            .navigationDestination(for: String.self) { value in
                Text("Destination: (value)")
            }
        }
    }
}

Notes

  • Use @State for local values and bindings for child views.
  • Extract subviews when the body grows.