Member-only story
Navigation Checkpoints in SwiftUI
Introducing a powerful tool for SwiftUI navigation.

From this point on I’m going to be referencing my new open source library Navigator and how it solves many of the problems inherent in SwiftUI navigation.
And one of those problems is one that we’ve all faced. How can we return to a specific place in the navigation tree?
Overview
Like most open sourced navigation systems based on NavigationStack
, Navigator supports operations like popping back to a previous view, dismissing a presented view, and so on.
Button("Pop To Previous Screen") {
navigator.pop()
}
Button("Dismiss Presented View") {
navigator.dismiss()
}
Handy operations to be sure, but they’re also imperative operations.
While one can programmatically pop and dismiss their way out of a screen, that approach is problematic and tends to be fragile. Why? Because it assumes that the code has explicit knowledge of the application structure and navigation tree.
One could pass bindings or callback handlers down the tree, but those can also be cumbersome and difficult to maintain.
Fortunately, Navigator supports checkpoints; named points in the navigation stack to which one can easily…