SwiftUI.js
Components

NavigationStack

NavigationStack is a container that manages a stack of views for navigation. NavigationStack provides navigation functionality similar to iOS navigation controllers, allowing users to navigate forward and backward through a hierarchy of views.

NavigationStack is a container that manages a stack of views for navigation. NavigationStack provides navigation functionality similar to iOS navigation controllers, allowing users to navigate forward and backward through a hierarchy of views.

Examples

Basic Usage

Preview unavailable for this example in the static docs build.

Show code
<NavigationStack>
        <VStack spacing={20}>
          <NavigationLink destination={Messages}>Message</NavigationLink>
          <NavigationLink destination={About}>About</NavigationLink>
          <NavigationLink destination={ZStackView}>ZStack</NavigationLink>
        </VStack>
      </NavigationStack>

Preloaded Path

Preview unavailable for this example in the static docs build.

Show code
<NavigationStack {...args}>
        <VStack spacing={20}>
          <NavigationLink destination={Messages}>Message</NavigationLink>
          <NavigationLink destination={About}>About</NavigationLink>
          <NavigationLink destination={ZStackView}>ZStack</NavigationLink>
        </VStack>
      </NavigationStack>

API

This component currently relies on inherited element props.

Overview

NavigationStack is a container that manages a stack of views for navigation. NavigationStack provides navigation functionality similar to iOS navigation controllers, allowing users to navigate forward and backward through a hierarchy of views.

SwiftUI Correspondence: Similar to SwiftUI's NavigationStack.

Notes

  • NavigationStack manages the navigation hierarchy
  • Use NavigationLink to navigate between views
  • NavigationStack automatically handles back navigation
  • Pages can be StandardPage or custom components
  • NavigationStack supports different page types (page, actionsheet)
  • Use defaultPath to render an already-pushed destination on first load
  • Use onPathChange to observe the public stack shape without reading internal _id values

Best Practices

  1. Page structure: Use StandardPage for consistent page layouts
  2. Navigation flow: Design clear navigation flows that users can understand
  3. Back navigation: Back navigation is handled automatically
  4. Deep linking: Consider deep linking support for important views
  5. State management: Manage navigation state appropriately for your app

On this page