Member-only story
NavigationStack
NavigationStack = Stack of Plates 🍽️
Important Components: -
NavigationStack(path:)
The container. Holds the stack. Accepts an optional $path binding for programmatic control.
.navigationDestination(for:)
Maps a type to a view. Declare once, works for all NavigationLinks and path appends of that type.
NavigationPath
Type-erased array. Can hold mixed types. append() = push. removeLast() = pop. Assign [] = go to root.
Tiny Example — Profile & Settings flow
import SwiftUI
// A simple data type we'll use for programmatic navigation
enum Screen: Hashable {
case profile(userID: Int)
case settings
}
struct ContentView: View {
@State private var path = [Screen]() // the navigation stack path
var body: some View {
NavigationStack(path: $path) {
VStack(spacing: 20) {
// 1. Simple NavigationLink with a value
NavigationLink("View Profile", value: Screen.profile(userID: 42))
// 2. Button that programmatically pushes a new screen
Button("Open Settings") {
path.append(.settings)
}…






