Skip to main content

Navigation

Expo Router provides multiple ways to navigate between screens: declarative Link components and imperative router methods. The Link component provides declarative navigation:

Basic Usage

Using with Custom Components

Use asChild to render a custom component:
Pass parameters using the href object:

Dynamic Hrefs

Construct hrefs dynamically:
Control navigation behavior:

Programmatic Navigation

Use the router object for imperative navigation:

router.push()

Navigate forward, adding to history:
From the source (imperative-api.tsx:48-50):

router.navigate()

Navigate to a route, replacing if already in stack:
From the source (imperative-api.tsx:52-54):

router.replace()

Replace current screen without adding to history:
From the source (imperative-api.tsx:56-62):

router.back()

Go back to previous screen:
From the source (imperative-api.tsx:40-42):

router.dismiss()

Dismiss screens in a modal or stack:
From the source (imperative-api.tsx:64-76):

router.dismissTo()

Dismiss until reaching a specific route:
From the source (imperative-api.tsx:70-72):

router.canGoBack()

Check if navigation can go back:

router.canDismiss()

Check if can dismiss current screen:
From the source (imperative-api.tsx:78-83):

router.setParams()

Update current route parameters:
From the source (imperative-api.tsx:85-87):

router.prefetch()

Prefetch a screen in the background:

useRouter()

Get the router object in a component:
From the source (hooks.ts:98-121):

usePathname()

Get current route pathname:
From the source (hooks.ts:177-196):

useSegments()

Get current route segments:
From the source (hooks.ts:132-175):

useLocalSearchParams()

Get route parameters for current screen:
From the source (hooks.ts:244-314):

useGlobalSearchParams()

Get parameters for globally selected route:
From the source (hooks.ts:198-242):
Configure navigation behavior:
From test file (navigation.test.ios.tsx:77-80):

Relative Paths

Use relative navigation:

External URLs

Navigate to external URLs:

Best Practices

Prefer <Link> for navigation that’s always visible:

Use Router for Dynamic Navigation

Use router for conditional or event-driven navigation:

Check Before Going Back

Always check if you can go back:

Prefetch Important Routes

Prefetch routes users are likely to visit:

Common Patterns

Authentication Flow

Conditional Navigation

Next Steps

Dynamic Routes

Work with route parameters

Layouts

Share UI across routes

Deep Linking

Configure deep links

Typed Routes

Type-safe navigation