How to Navigate to Another View in SwiftUI

October 13, 2025·1 min read·by dockui

How to Navigate to Another View in SwiftUI

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.

Similar Blogs

View All Articles
SwiftUI: How To Reset a Form

SwiftUI: How To Reset a Form

Learn how to reset a SwiftUI form with one line. Clear text fields instantly using @State or a form model. Simple copy/paste SwiftUI code examples.

by dockui
Nov 10
SwiftUI: How To Toggle a Switch Programmatically

SwiftUI: How To Toggle a Switch Programmatically

Learn how to toggle a SwiftUI switch programmatically with @State and @Binding. Simple examples with code to trigger Toggle from buttons or other views.

by dockui
Nov 10
How to use @AppStorage in SwiftUI

How to use @AppStorage in SwiftUI

Learn how to use @AppStorage in SwiftUI to save user settings and preferences easily with UserDefaults

by dockui
Oct 17
How to Make Text Selectable in SwiftUI

How to Make Text Selectable in SwiftUI

Learn how to make text selectable in SwiftUI using the .textSelection(.enabled) modifier. Enable text copying and selection easily in iOS 15 and later with

by dockui
Oct 13

Code copied to clipboard!