Thuta Learning
IntermediateMobile Developmentintermediate

Navigation Basics (NavigationStack)

Relax. We'll talk through this in plain words — no textbook voice.

What you'll walk away with

  • Understand Navigation Basics (NavigationStack) with nothing to be intimidated by
  • Get comfortable running Xcode/SwiftUI code yourself
  • Be able to apply this concept in a real project right away

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

swift
struct AppNavigation: View {
    var body: some View {
        NavigationStack {
            HomeScreen()
        }
    }
}

struct HomeScreen: View {
    var body: some View {
        NavigationLink("Go to Detail") {
            DetailScreen()
        }
        .navigationTitle("Home")
    }
}
You should see
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.

Easy traps

  • Not knowing that `NavigationStack` should only be placed once at the root level, and nesting it inside child Views instead — this can make navigation behavior confusing
  • Forgetting to add `.navigationTitle()` on each screen — the navigation bar title can end up empty

Now try it yourself

Write `AppNavigation`/`HomeScreen`/`DetailScreen` yourself and actually try Home → Detail → back (including the swipe-back gesture) on the Simulator.

You'll know it worked when: 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.

Navigation Basics (NavigationStack) | Thuta Learning