Let's think about it this way for a second
`NavigationStack` is a container that manages the history of screens (Views) as a stack — tapping a `NavigationLink` pushes you forward to a new View, and tapping the top-left back button (which appears automatically) pops you back to the previous screen. It's similar in concept to Android/Compose's NavController.navigate()/popBackStack(), except on iOS you don't have to write the back button yourself — it comes for free.
Let's connect this to a real-world scenario
If you place `NavigationStack { HomeScreen() }` at the root, and inside `HomeScreen` write `NavigationLink("Go to Detail") { DetailScreen() }` — tapping it takes you to `DetailScreen`, and tapping the automatic back button in the top-left (< Home) brings you right back to `HomeScreen`.
Let's look at it together
struct AppNavigation: View {
var body: some View {
NavigationStack {
HomeScreen()
}
}
}
struct HomeScreen: View {
var body: some View {
NavigationLink("Go to Detail") {
DetailScreen()
}
.navigationTitle("Home")
}
}Tapping the 'Go to Detail' link takes you to DetailScreen, and you can go back to Home using the back button in the top-left.5-minute try-it
Write `AppNavigation`/`HomeScreen`/`DetailScreen` yourself and actually try Home → Detail → back (including the swipe-back gesture) on the Simulator.
A quick heads-up
Be careful not to let a custom gesture handler (`onTapGesture`, `DragGesture`) conflict with and override iOS's built-in 'swipe from left edge to go back' gesture — that breaks user expectations.