How to Navigate to Another View in SwiftUI (Complete Guide)

October 13, 2025·1 min read·by dockui

How to Navigate to Another View in SwiftUI (Complete Guide)

Starting from iOS 16, Apple introduced the new NavigationStack API, which replaces NavigationView and makes navigation more powerful and reliable.

NavigationStack and NavigationLink (iOS 16+

In modern SwiftUI, NavigationStack is the container for managing navigation between views. Inside it, you use NavigationLink to move from one view to another.

Here’s the simplest example 👇

Code Snippet

When you tap “Go to Detail View”, SwiftUI smoothly navigates to the next screen.

How NavigationLink Works

A NavigationLink automatically pushes the new view onto the navigation stack.
You don’t need to manage transitions manually — SwiftUI handles back navigation, animations, and state.

Passing Data Between Views

You can easily send data to another view using properties or bindings.

Code Snippet

Navigation in iOS 17 and Later

In iOS 17, Apple further refined NavigationStack and introduced navigation destinations with typed data:

Code Snippet

This lets you build complex navigation flows with type-safe data-driven navigation — perfect for large apps.

Code copied to clipboard!