Sitemap
Niraj Paul

Niraj Paul

Senior iOS Developer & Mobile Architect | 11+ Years | Swift, SwiftUI, tvOS & OTT | Building Apps, Exploring AI & Share https://resume.nirajpaul.com

Member-only story

NavigationStack

3 min readJun 4, 2026

--

NavigationStack = Stack of Plates 🍽️

Press enter or click to view image in full size

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)
}…

--

--

Senior iOS Developer & Mobile Architect | 11+ Years | Swift, SwiftUI, tvOS & OTT | Building Apps, Exploring AI & Share https://resume.nirajpaul.com