3 min readMar 14, 2026
SwiftHow to Use NavigationStack
Build navigation using the modern API.
Steps
- Paste the view into a SwiftUI file.
- Set it as a preview or root view.
- 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.
