Navigation
Expo Router provides multiple ways to navigate between screens: declarativeLink components and imperative router methods.
Link Component
TheLink component provides declarative navigation:
Basic Usage
Using with Custom Components
UseasChild to render a custom component:
Link with Parameters
Pass parameters using thehref object:
Dynamic Hrefs
Construct hrefs dynamically:Link Behavior
Control navigation behavior:Programmatic Navigation
Use therouter object for imperative navigation:
router.push()
Navigate forward, adding to history:imperative-api.tsx:48-50):
router.navigate()
Navigate to a route, replacing if already in stack:imperative-api.tsx:52-54):
router.replace()
Replace current screen without adding to history:imperative-api.tsx:56-62):
router.back()
Go back to previous screen:imperative-api.tsx:40-42):
router.dismiss()
Dismiss screens in a modal or stack:imperative-api.tsx:64-76):
router.dismissTo()
Dismiss until reaching a specific route:imperative-api.tsx:70-72):
router.canGoBack()
Check if navigation can go back:router.canDismiss()
Check if can dismiss current screen:imperative-api.tsx:78-83):
router.setParams()
Update current route parameters:imperative-api.tsx:85-87):
router.prefetch()
Prefetch a screen in the background:Navigation Hooks
useRouter()
Get the router object in a component:hooks.ts:98-121):
usePathname()
Get current route pathname:hooks.ts:177-196):
useSegments()
Get current route segments:hooks.ts:132-175):
useLocalSearchParams()
Get route parameters for current screen:hooks.ts:244-314):
useGlobalSearchParams()
Get parameters for globally selected route:hooks.ts:198-242):
Navigation Options
Configure navigation behavior:navigation.test.ios.tsx:77-80):
Relative Paths
Use relative navigation:External URLs
Navigate to external URLs:Best Practices
Use Links for Static Navigation
Prefer<Link> for navigation that’s always visible:
Use Router for Dynamic Navigation
Userouter 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
Modal Navigation
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