Advanced Navigation Destinations in SwiftUI

A set of powerful techniques that might just change how you view navigation in SwiftUI. Forever.

Michael Long
10 min readJan 9, 2025

Two years ago Apple revamped navigation in iOS 16 with the introduction of NavigationStack, NavigationLink(value:label:), NavigationPath, and the navigationDestination modifer.

While NavigationStack and NavigationPath opened up the door to imperative, programatic navigation techniques, I’m of the option that NavigationLink value was the true game changer.

With NavigationLink value you no longer had to deal with a view explicitly defining its destination inside of each and every NavigationLink.

NavigationLink("View Account") {
AccountDetailView(viewModel: AccountDetailsViewModel(account: selectedAccount))
}

Nor did you have to worry about overly eager evaluations of the destination view that lead so many of us astray. Just “push” a value onto the navigation stack…

List {
NavigationLink("View Account", value: selectedAccount)
}

And a navigationDestination handler specified somewhere in the code will match the type of the pushed value and create the desired view for you.

.navigationDestination(Account.self) { account in…

--

--

Michael Long
Michael Long

Written by Michael Long

I write about Apple, Swift, and SwiftUI in particular, and technology in general. I'm also a Lead iOS Engineer at InRhythm, a modern digital consulting firm.

Responses (7)