Routing
How to route
Use the built in hook from expo-router to handle navigation
Automatic Routing
What is Automatic Routing
Automatic Routing automatically routes your app to the correct screen based on the configs you have set up and the state of the app. If the user has not completed onboarding, it will display the onboarding screen. If the user has not logged, it will display the auth screen. Etc.
How to use
Just use navigation.replace("/")
to redirect to the root screen of the app. This page will automatically route you to the correct page based on the app state
How it works
Automatic routing is handled by the useEffect
in /app/index.tsx
.
If
config.requireOnboarding
is set, but the user has not completed onboarding, redirect to the onboarding pageif
config.requireAuth
is set, but the user is not logged in, redirect to the onboarding pageAfter
signIn
,signOut
, etc. are called, the page will redirect to the root screen"/"
and then is rerouted to the correct page
Custom Behavior
Modify the useEffect
in /app/index.tsx
to customize the behavior of the routing. For example, to force the user to authenticate before they do the onboarding, reorder the if statements
Last updated