This is documentation for the next SDK version. For up-to-date documentation, see the latest version (SDK 54).
Expo Router
A file-based routing library for React Native and web applications.
expo-router is a routing library for React Native and web apps. It enables navigation management using a file-based routing system and provides native navigation components and is built on top of React Navigation.
Learn about Expo Router basics, navigation patterns, core concepts, and more.
Installation
To use Expo Router in your project, you need to install. Follow the instructions from the Expo Router's installation guide:
Learn how to install Expo Router in your project.
Configuration in app config
If you are using the default template to create a new project, expo-router's config plugin is already configured in your app config.
Example app.json with config plugin
{ "expo": { "plugins": ["expo-router"] } }
Usage
For information core concepts, notation patterns, navigation layouts, and common navigation patterns, start with Router 101 section:
API
import { Stack, Tabs, Link } from 'expo-router';
Components
Type: React.Element<LinkProps>
Component that renders a link using href to another route.
By default, it accepts children and wraps them in a <Text> component.
Uses an anchor tag (<a>) on web and performs a client-side navigation to preserve
the state of the website and navigate faster. The web-only attributes such as target,
rel, and download are supported and passed to the anchor tag on web. See
WebAnchorProps for more details.
Note: Client-side navigation works with both single-page apps, and static-rendering.
Example
import { Link } from 'expo-router'; import { View } from 'react-native'; export default function Route() { return ( <View> <Link href="/about">About</Link> </View> ); }
booleanUsed to customize the Link component. It will forward all props to the
first child of the Link. Note that the child component must accept
onPress or onClick props. The href and role are also
passed to the child.
Example
import { Link } from 'expo-router'; import { Pressable, Text } from 'react-native'; export default function Route() { return ( <View> <Link href="/home" asChild> <Pressable> <Text>Home</Text> </Pressable> </Link> </View> ); }
stringOn native, this can be used with CSS interop tools like Nativewind.
On web, this sets the HTML class directly.
SingularOptionsWhen navigating in a Stack, if the target is valid then screens in the history that matches the uniqueness constraint will be removed.
If used with push, the history will be filtered even if no navigation occurs.
booleanWhile in a stack, this will dismiss screens until the provided href is reached. If the href is not found,
it will instead replace the current screen with the provided href.
Example
import { Link } from 'expo-router'; import { View } from 'react-native'; export default function Route() { return ( <View> <Link dismissTo href="/feed">Close modal</Link> </View> ); }
unionThe path of the route to navigate to. It can either be:
- string: A full path like
/profile/settingsor a relative path like../settings. - object: An object with a
pathnameand optionalparams. Thepathnamecan be a full path like/profile/settingsor a relative path like../settings. The params can be an object of key-value pairs.
Example
import { Link } from 'expo-router'; import { View } from 'react-native'; export default function Route() { return ( <View> <Link href="/about">About</Link> <Link href={{ pathname: '/user/[id]', params: { id: 'bacon' } }}> View user </Link> </View> ); }
Acceptable values are: string | HrefObject
(event: MouseEvent<HTMLAnchorElement, MouseEvent> | GestureResponderEvent) => voidThis function is called on press. Text intrinsically supports press handling with a default highlight state (which can be disabled with suppressHighlighting).
booleanPrefetches the route when the component is rendered on a focused screen.
booleanAlways pushes a new route, and never pops or replaces to existing route. You can push the current route multiple times or with new parameters.
Example
import { Link } from 'expo-router'; import { View } from 'react-native'; export default function Route() { return ( <View> <Link push href="/feed">Login</Link> </View> ); }
booleanRelative URL references are either relative to the directory or the document. By default, relative paths are relative to the document.
booleanRemoves the current route from the history and replace it with the specified URL. This is useful for redirects.
Example
import { Link } from 'expo-router'; import { View } from 'react-native'; export default function Route() { return ( <View> <Link replace href="/feed">Login</Link> </View> ); }
booleanReplaces the initial screen with the current route.
Inherited Props
Omit<TextProps, 'href'>WebAnchorProps
Type: React.Element<React.FC<LinkMenuProps>>
Groups context menu actions for a link.
If multiple Link.Menu components are used within a single Link, only the first will be rendered.
Only Link.MenuAction and LinkMenuAction components are allowed as children.
Example
<Link.Menu> <Link.MenuAction title="Action 1" onPress={() => {}} /> <Link.MenuAction title="Action 2" onPress={() => {}} /> </Link.Menu>
Note: You can use the alias
Link.Menufor this component.
ReactNodebooleanIf true, the menu item will be displayed as destructive.
See: Apple documentation for more information.
stringThe preferred size of the menu elements.
elementSize property is ignored when palette is used.
See: Apple documentation for more information.
Acceptable values are: 'small' | 'medium' | 'auto' | 'large'
booleanIf true, the menu will be displayed inline.
This means that the menu will not be collapsed
See: Apple documentation for more information.
booleanIf true, the menu will be displayed as a palette.
This means that the menu will be displayed as one row.
The elementSize property is ignored when palette is used, all items will be elementSize="small". Use elementSize="medium" instead of palette to display actions with titles horizontally.
Note: Palette menus are only supported in submenus.
See: Apple documentation for more information.
stringAn optional subtitle for the submenu. Does not appear on inline menus.
See: Apple documentation for more information.
Type: React.Element<StackHeaderProps>
The component used to configure the whole stack header.
When used inside a screen, it allows you to customize the header dynamically by composing header subcomponents (title, left/right areas, back button, search bar, etc.).
import { Stack } from 'expo-router'; export default function Page() { return ( <> <Stack.Header> <Stack.Header.Title>Page title</Stack.Header.Title> <Stack.Header.Left> <Stack.Header.Button onPress={() => alert('Left pressed')} /> </Stack.Header.Left> <Stack.Header.Right> <Stack.Header.Button onPress={() => alert('Right pressed')} /> </Stack.Header.Right> </Stack.Header> <ScreenContent /> </> ); }
When used inside a layout, it needs to be wrapped in Stack.Screen to take effect.
Example (inside a layout):
import { Stack } from 'expo-router'; export default function Layout() { return ( <Stack> <Stack.Screen name="index"> <Stack.Header> <Stack.Header.Title>Layout title</Stack.Header.Title> <Stack.Header.Right> <Stack.Header.Button onPress={() => alert('Right pressed')} /> </Stack.Header.Right> </Stack.Header> </Stack.Screen> </Stack> ); }
boolean • Default: falseWhen true, renders children as a custom header component, replacing the default header entirely.
Use this to implement fully custom header layouts.
BlurEffectTypesThe blur effect to apply to the header background on iOS. Common values include 'regular', 'prominent', 'systemMaterial', etc.
ReactNodeChild elements to compose the header. Can include Stack.Header.Title, Stack.Header.Left, Stack.Header.Right, Stack.Header.BackButton, and Stack.Header.SearchBar components.
boolean • Default: falseWhether to hide the header completely. When set to true, the header will not be rendered.
StyleProp<{
backgroundColor: ColorValue,
shadowColor: 'transparent'
}>Style properties for the large title header (iOS).
backgroundColor: Background color of the large title headershadowColor: Set to 'transparent' to hide the large title shadow/border
StyleProp<{
backgroundColor: ColorValue,
color: ColorValue,
shadowColor: 'transparent'
}>Style properties for the standard-sized header.
color: Tint color for header elements (similar to tintColor in React Navigation)backgroundColor: Background color of the headershadowColor: Set to 'transparent' to hide the header shadow/border
Type: React.Element<React.FC<StackHeaderBadgeProps>>
Type: React.Element<React.FC<StackHeaderButtonProps>>
A header button used inside Stack.Header.Left or Stack.Header.Right.
See: Human Interface Guidelines for more information about navigation bar items on iOS.
Example
import { Stack } from 'expo-router'; export default function Screen() { return ( <> <ScreenContent /> <Stack.Screen> <Stack.Header> <Stack.Header.Left> <Stack.Header.Button tintColor="blue" icon="arrow.left.circle" onPress={() => alert('Left pressed')} /> <Stack.Header.Button style={{ color: 'green' }} onPress={() => alert('2 pressed')}> <Stack.Header.Label>2</Stack.Header.Label> </Stack.Header.Button> </Stack.Header.Left> </Stack.Header> </Stack.Screen> </> ); }
ReactNodeThere are two ways to specify the content of the header item:
Example
import { Stack } from 'expo-router'; ... <Stack.Header.Button icon="star.fill">As text passed as children</Stack.Header.Button>
Example
import { Stack } from 'expo-router'; ... <Stack.Header.Button> <Stack.Header.Icon sf="star.fill" /> <Stack.Header.Label>As components</Stack.Header.Label> <Stack.Header.Badge>3</Stack.Header.Badge> </Stack.Header.Button>
Note: When icon is used, the label will not be shown and will be used for accessibility purposes only.
booleanWhether to hide the shared background.
See: Official Apple documentation for more information.
unionIcon to display in the button.
Can be a string representing an SFSymbol or an image source.
Acceptable values are: ImageSourcePropType | SFSymbols6_0
booleanWhether the button is in a selected state
See: Apple documentation for more information.
boolean • Default: falseWhether to separate the background of this item from other header items.
ColorValueThe tint color to apply to the button item
See: Apple documentation for more information.
Type: React.Element<React.FC<StackHeaderIconProps>>
ImageSourcePropTypeSFSymbolType: React.Element<React.FC<StackHeaderLabelProps>>
Type: React.Element<React.FC<StackHeaderLeftProps>>
The component used to configure the left area of the stack header.
When used inside a screen, it allows you to customize the left side of the header dynamically.
Example
import { Stack } from 'expo-router'; export default function Page() { return ( <> <Stack.Header.Left> <Stack.Header.Button onPress={() => alert('Left button pressed!')} /> </Stack.Header.Left> <ScreenContent /> </> ); }
When used inside the layout, it needs to be wrapped in Stack.Header to take effect.
Example
import { Stack } from 'expo-router'; export default function Layout() { return ( <Stack> <Stack.Screen name="index"> <Stack.Header> <Stack.Header.Left> <Stack.Header.Button onPress={() => alert('Left button pressed!')} /> </Stack.Header.Left> </Stack.Header> </Stack.Screen> </Stack> ); }
boolean • Default: falseWhen true, renders children as a custom component in the header left area,
replacing the default header left layout.
ReactNodeChild elements to compose the left area of the header. Can include Stack.Header.Button, Stack.Header.Menu, Stack.Header.Item, and Stack.Header.Spacer components.
Type: React.Element<React.FC<StackHeaderMenuProps>>
Component representing menu for Stack.Header.Right or Stack.Header.Left.
Use as Stack.Header.Menu to provide top-level menus on iOS header bars.
It accepts Stack.Header.MenuAction and nested Stack.Header.Menu
elements. Menu can be configured using both component props and child
elements.
See: Human Interface Guidelines for more information about menus on iOS.
Example
import { Stack } from 'expo-router'; import { Alert } from 'react-native'; export default function Screen() { return ( <> <ScreenContent /> <Stack.Screen> <Stack.Header> <Stack.Header.Right> <Stack.Header.Menu> <Stack.Header.Label>Menu</Stack.Header.Label> <Stack.Header.Icon sf="ellipsis.circle" /> <Stack.Header.MenuAction onPress={() => Alert.alert('Action 1 pressed!')}> Action 1 </Stack.Header.MenuAction> <Stack.Header.MenuAction isOn icon="star.fill"> Action 2 </Stack.Header.MenuAction> <Stack.Header.Menu inline> <Stack.Header.MenuAction isOn>Sub Action</Stack.Header.MenuAction> </Stack.Header.Menu> </Stack.Header.Menu> </Stack.Header.Right> </Stack.Header> </Stack.Screen> </> ); }
Example
import { Stack } from 'expo-router'; import { Text } from 'react-native'; export default function Screen() { return ( <> <ScreenContent /> <Stack.Screen> <Stack.Header> <Stack.Header.Left> <Stack.Header.Menu> <Stack.Header.MenuAction onPress={() => Alert.alert('Action 1 pressed!')}> Action 1 </Stack.Header.MenuAction> <Stack.Header.Menu inline palette title="Icons"> <Stack.Header.MenuAction isOn icon="star.fill" /> <Stack.Header.MenuAction icon="heart.fill" /> </Stack.Header.Menu> </Stack.Header.Menu> </Stack.Header.Left> </Stack.Header> </Stack.Screen> </> ); }
ReactNodeThere are two ways to specify the content of the menu header item - using props or child components:
Example
import { Stack } from 'expo-router'; ... <Stack.Header.Menu icon="star.fill" title="As props"> <Stack.Header.MenuAction>Action 1</Stack.Header.MenuAction> </Stack.Header.Menu>
Example
import { Stack } from 'expo-router'; ... <Stack.Header.Menu> <Stack.Header.Icon sf="star.fill" /> <Stack.Header.Label>As components</Stack.Header.Label> <Stack.Header.Badge>3</Stack.Header.Badge> <Stack.Header.MenuAction>Action 1</Stack.Header.MenuAction> </Stack.Header.Menu>
Note: When icon is used, the label will not be shown and will be used for accessibility purposes only.
booleanIf true, the menu item will be displayed as destructive.
See: Apple documentation for more information.
booleanWhether to hide the shared background.
See: Official Apple documentation for more information.
unionIcon for the menu item.
Can be an SF Symbol name or an image source.
Acceptable values are: ImageSourcePropType | SFSymbols6_0
booleanIf true, the menu will be displayed inline.
This means that the menu will not be collapsed
*Note: Inline menus are only supported in submenus.
See: Apple documentation for more information.
booleanIf true, the menu will be displayed as a palette.
This means that the menu will be displayed as one row
Note: Palette menus are only supported in submenus.
See: Apple documentation for more information.
boolean • Default: falseWhether to separate the background of this item from other header items.
ColorValueThe tint color to apply to the button item
See: Apple documentation for more information.
Type: React.Element<React.FC<StackHeaderMenuActionProps>>
An action item for a Stack.Header.Menu.
See: Human Interface Guidelines for more information about menus on iOS.
Example
import React from 'react'; import { Alert } from 'react-native'; import { Stack, Label, Icon } from 'expo-router'; export default function ExampleScreen() { return ( <> <ScreenContent /> <Stack.Screen> <Stack.Header> <Stack.Header.Right> <Stack.Header.Menu icon="ellipsis.circle"> <Stack.Header.MenuAction onPress={() => Alert.alert('Action 1 pressed!')}> Action 1 </Stack.Header.MenuAction> <Stack.Header.MenuAction isOn onPress={() => Alert.alert('Action 2 pressed!')}> <Label>Action 2</Label> <Icon sf="star.fill" /> </Stack.Header.MenuAction> </Stack.Header.Menu> </Stack.Header.Right> </Stack.Header> </Stack.Screen> </> ); }
booleanIf true, the menu item will be displayed as destructive.
See: Apple documentation for more information.
booleanIf true, the menu item will be disabled and not selectable.
See: Apple documentation for more information.
stringAn elaborated title that explains the purpose of the action.
unionAcceptable values are: ImageSourcePropType | SFSymbols6_0
stringAn optional subtitle for the menu item.
See: Apple documentation for more information.
booleanIf true, the menu will be kept presented after the action is selected.
This is marked as unstable, because when action is selected it will recreate the menu, which will close all opened submenus and reset the scroll position.
See: Apple documentation for more information.
Type: React.Element<React.FC<StackHeaderRightProps>>
The component used to configure the right area of the stack header.
When used inside a screen, it allows you to customize the right side of the header dynamically.
Example
import { Stack } from 'expo-router'; export default function Page() { return ( <> <Stack.Header.Right> <Stack.Header.Button onPress={() => alert('Right button pressed!')} /> </Stack.Header.Right> <ScreenContent /> </> ); }
When used inside the layout, it needs to be wrapped in Stack.Header to take effect.
Example
import { Stack } from 'expo-router'; export default function Layout() { return ( <Stack> <Stack.Screen name="index"> <Stack.Header> <Stack.Header.Right> <Stack.Header.Button onPress={() => alert('Right button pressed!')} /> </Stack.Header.Right> </Stack.Header> </Stack.Screen> </Stack> ); }
boolean • Default: falseWhen true, renders children as a custom component in the header right area,
replacing the default header right layout.
ReactNodeChild elements to compose the right area of the header. Can include Stack.Header.Button, Stack.Header.Menu, Stack.Header.Item, and Stack.Header.Spacer components.
Type: React.Element<React.FC<StackHeaderSpacerProps>>
A spacing helper used inside Stack.Header.Left or Stack.Header.Right to create
empty space between header items.
Example
import { Stack } from 'expo-router'; export default function Screen() { return ( <> <ScreenContent /> <Stack.Screen> <Stack.Header> <Stack.Header.Left> <Stack.Header.Button icon="arrow.left" /> <Stack.Header.Spacer width={8} /> <Stack.Header.Button icon="arrow.right" /> </Stack.Header.Left> </Stack.Header> </Stack.Screen> </> ); }
Type: React.Element<React.FC<StackHeaderViewProps>>
A wrapper to render custom content in the header.
Use as Stack.Header.Item to render a custom React element into the header
Example
import { Stack } from 'expo-router'; import { Text } from 'react-native'; function CustomHeaderElement() { return <Text>Custom Element</Text>; } function Screen() { return ( <> <ScreenContent /> <Stack.Screen> <Stack.Header> <Stack.Header.Left> <Stack.Header.Item> <CustomHeaderElement /> </Stack.Header.Item> </Stack.Header.Left> </Stack.Header> </Stack.Screen> </> ); }
boolean • Default: falseWhen true, renders children as a custom header component, replacing the default header entirely.
Use this to implement fully custom header layouts.
BlurEffectTypesThe blur effect to apply to the header background on iOS. Common values include 'regular', 'prominent', 'systemMaterial', etc.
ReactNodeChild elements to compose the header. Can include Stack.Header.Title, Stack.Header.Left, Stack.Header.Right, Stack.Header.BackButton, and Stack.Header.SearchBar components.
boolean • Default: falseWhether to hide the header completely. When set to true, the header will not be rendered.
StyleProp<{
backgroundColor: ColorValue,
shadowColor: 'transparent'
}>Style properties for the large title header (iOS).
backgroundColor: Background color of the large title headershadowColor: Set to 'transparent' to hide the large title shadow/border
StyleProp<{
backgroundColor: ColorValue,
color: ColorValue,
shadowColor: 'transparent'
}>Style properties for the standard-sized header.
color: Tint color for header elements (similar to tintColor in React Navigation)backgroundColor: Background color of the headershadowColor: Set to 'transparent' to hide the header shadow/border
ReactElement<unknown, string | JSXElementConstructor<any>>Can be any React node.
booleanWhether to hide the shared background.
See: Official Apple documentation for more information.
Type: React.Element<BadgeProps>
Type: React.Element<ErrorBoundaryProps>
Type: React.Element<LabelProps>
Type: React.Element<LinkMenuActionProps>
This component renders a context menu action for a link.
It should only be used as a child of Link.Menu or LinkMenu.
Note: You can use the alias
Link.MenuActionfor this component.
booleanIf true, the menu item will be displayed as destructive.
See: Apple documentation for more information.
booleanIf true, the menu item will be disabled and not selectable.
See: Apple documentation for more information.
stringAn elaborated title that explains the purpose of the action.
boolean • Default: falseWhether the menu element should be hidden.
See: Apple documentation for more information.
stringAn optional subtitle for the menu item.
See: Apple documentation for more information.
Deprecated Use
childrenprop instead.
stringThe title of the menu item.
booleanIf true, the menu will be kept presented after the action is selected.
This is marked as unstable, because when action is selected it will recreate the menu, which will close all opened submenus and reset the scroll position.
See: Apple documentation for more information.
Type: React.Element<LinkPreviewProps>
A component used to render and customize the link preview.
If Link.Preview is used without any props, it will render a preview of the href passed to the Link.
If multiple Link.Preview components are used within a single Link, only the first one will be rendered.
To customize the preview, you can pass custom content as children.
Example
<Link href="/about"> <Link.Preview> <Text>Custom Preview Content</Text> </Link.Preview> </Link>
Example
<Link href="/about"> <Link.Preview /> </Link>
Note: You can use the alias
Link.Previewfor this component.
ReactNodeLinkPreviewStyleCustom styles for the preview container.
Note that some styles may not work, as they are limited or reset by the native view
Type: React.Iterable<LinkTriggerProps>
Serves as the trigger for a link. The content inside this component will be rendered as part of the base link.
If multiple Link.Trigger components are used within a single Link, only the first will be rendered.
Example
<Link href="/about"> <Link.Trigger> Trigger </Link.Trigger> </Link>
Note: You can use the alias
Link.Triggerfor this component.
booleanA shorthand for enabling the Apple Zoom Transition on this link trigger.
When set to true, the trigger will be wrapped with Link.AppleZoom.
If another Link.AppleZoom is already used inside Link.Trigger, an error
will be thrown.
Type: React.Element<RedirectProps>
Redirects to the href as soon as the component is mounted.
Example
import { View, Text } from 'react-native'; import { Redirect } from 'expo-router'; export default function Page() { const { user } = useAuth(); if (!user) { return <Redirect href="/login" />; } return ( <View> <Text>Welcome Back!</Text> </View> ); }
HrefThe path of the route to navigate to. It can either be:
- string: A full path like
/profile/settingsor a relative path like../settings. - object: An object with a
pathnameand optionalparams. Thepathnamecan be a full path like/profile/settingsor a relative path like../settings. The params can be an object of key-value pairs.
Example
import { Redirect } from 'expo-router'; export default function RedirectToAbout() { return ( <Redirect href="/about" /> ); }
booleanRelative URL references are either relative to the directory or the document. By default, relative paths are relative to the document.
Type: React.Element<Omit<NavigatorProps<any>, 'children'>>
Renders the currently selected content.
There are actually two different implementations of <Slot/>:
- Used inside a
_layoutas theNavigator - Used inside a
Navigatoras the content
Since a custom Navigator will set the NavigatorContext.contextKey to
the current _layout, you can use this to determine if you are inside
a custom navigator or not.
Type: React.Element<StackHeaderBackButtonProps>
BackButtonDisplayModeImageSourcePropTypeType: React.Element<StackHeaderSearchBarProps>
Type: React.Element<StackHeaderTitleProps>
StyleProp<{
color: string,
fontFamily: TextStyle[fontFamily],
fontSize: TextStyle[fontSize],
fontWeight: Exclude<TextStyle[fontWeight], number>
}>StyleProp<{
color: string,
fontFamily: TextStyle[fontFamily],
fontSize: TextStyle[fontSize],
fontWeight: Exclude<TextStyle[fontWeight], number>,
textAlign: 'left' | 'center'
}>Type: React.Element<StackScreenProps>
NativeStackNavigationOptionsType: React.Element<VectorIconProps<NameT>>
Helper component which can be used to load vector icons.
Example
import { Icon, VectorIcon } from 'expo-router'; import MaterialCommunityIcons from '@expo/vector-icons/MaterialCommunityIcons'; <Icon src={<VectorIcon family={MaterialCommunityIcons} name="home" />} />
{
getImageSource: (name: NameT, size: number, color: ColorValue) => Promise<ImageSourcePropType | null>
}The family of the vector icon.
Example
import MaterialCommunityIcons from '@expo/vector-icons/MaterialCommunityIcons';
Constants
Type: ColorType
Color utility to access platform-specific colors easily.
On Android, it provides access to:
- System colors, as a type-safe wrapper over
PlatformColor. For example,Color.android.background. - Attribute colors, as a type-safe wrapper over
PlatformColor. For example,Color.android.attr.colorPrimary. - Material Design 3 static colors. For example,
Color.android.material.primary. - Material Design 3 dynamic colors. For example,
Color.android.dynamic.primary.
On iOS, it is a type-safe wrapper over PlatformColor, providing access to system colors. For example, Color.ios.label.
Note: To ensure the colors align with the system theme on Android, make sure they are used within a component that responds to theme changes, such as by using the
useColorSchemehook from React Native.
Example
import { Color } from 'expo-router'; Color.ios.label; // Access iOS system color Color.android.background; // Access Android system color Color.android.attr.colorPrimary; // Access Android attribute color Color.android.material.primary; // Access Android Material Design 3 static color Color.android.dynamic.primary; // Access Android Material Design 3 dynamic color
Example
import { Color } from 'expo-router'; import { View, Text, useColorScheme } from 'react-native'; export default function MyComponent() { useColorScheme(); // Ensure the app responds to system theme changes return ( <View style={{ flex: 1, backgroundColor: Color.android.dynamic.primary }}> <Text style={{ color: Color.android.dynamic.onPrimary }}> Hello, World! </Text> </View> ); }
Type: {
addListener: (eventType: EventType, callback: (event: Payload<EventType>) => void) => () => void,
emit: (type: EventType, event: Payload<EventType>) => void,
}
Hooks
| Parameter | Type | Description |
|---|---|---|
| effect | EffectCallback | Memoized callback containing the effect, should optionally return a cleanup function. |
| do_not_pass_a_second_prop(optional) | undefined | - |
Hook to run an effect whenever a route is focused. Similar to
React.useEffect.
This can be used to perform side-effects such as fetching data or subscribing to events.
The passed callback should be wrapped in React.useCallback
to avoid running the effect too often.
voidExample
import { useFocusEffect } from 'expo-router'; import { useCallback } from 'react'; export default function Route() { useFocusEffect( // Callback should be wrapped in `React.useCallback` to avoid running the effect too often. useCallback(() => { // Invoked whenever the route is focused. console.log("Hello, I'm focused!"); // Return function is invoked whenever the route gets out of focus. return () => { console.log('This route is now unfocused.'); }; }, []), ); return </>; }
Returns URL parameters for globally selected route, including dynamic path segments. This function updates even when the route is not focused. Useful for analytics or other background operations that don't draw to the screen.
Route URL example: acme://profile/baconbrix?extra=info.
When querying search params in a stack, opt-towards using
useLocalSearchParams because it will only update when the route is focused.
Note: For usage information, see Local versus global search parameters.
RouteParams<TRoute> & TParamsExample
import { Text } from 'react-native'; import { useGlobalSearchParams } from 'expo-router'; export default function Route() { // user=baconbrix & extra=info const { user, extra } = useGlobalSearchParams(); return <Text>User: {user}</Text>; }
Hook to determine if the current route is rendered inside a preview.
boolean- True if the current route is rendered inside a preview, false otherwise.
Returns the result of the loader function for the calling route.
LoaderFunctionResult<T>Example
import { Text } from 'react-native'; import { useLoaderData } from 'expo-router'; export function loader() { return Promise.resolve({ foo: 'bar' }} } export default function Route() { // { foo: 'bar' } const data = useLoaderData<typeof loader>(); return <Text>Data: {JSON.stringify(data)}</Text>; }
Returns the URL parameters for the contextually focused route. Useful for stacks where you may push a new screen that changes the query parameters. For dynamic routes, both the route parameters and the search parameters are returned.
Route URL example: acme://profile/baconbrix?extra=info.
To observe updates even when the invoking route is not focused, use useGlobalSearchParams.
Note: For usage information, see Local versus global search parameters.
RouteParams<TRoute> & TParamsExample
import { Text } from 'react-native'; import { useLocalSearchParams } from 'expo-router'; export default function Route() { // user=baconbrix & extra=info const { user, extra } = useLocalSearchParams(); return <Text>User: {user}</Text>; }
| Parameter | Type | Description |
|---|---|---|
| parent(optional) | string | HrefObject | Provide an absolute path such as |
Returns the underlying React Navigation navigation object
to imperatively access layout-specific functionality like navigation.openDrawer() in a
Drawer layout.
TThe navigation object for the current route.
See: React Navigation documentation on navigation dependent functions for more information.
Example
import { useNavigation } from 'expo-router'; export default function Route() { // Access the current navigation object for the current route. const navigation = useNavigation(); return ( <View> <Text onPress={() => { // Open the drawer view. navigation.openDrawer(); }}> Open Drawer </Text> </View> ); }
When using nested layouts, you can access higher-order layouts by passing a secondary argument denoting the layout route.
For example, /menu/_layout.tsx is nested inside /app/orders/, you can use useNavigation('/orders/menu/').
Example
import { useNavigation } from 'expo-router'; export default function MenuRoute() { const rootLayout = useNavigation('/'); const ordersLayout = useNavigation('/orders'); // Same as the default results of `useNavigation()` when invoked in this route. const parentLayout = useNavigation('/orders/menu'); }
If you attempt to access a layout that doesn't exist, an error such as
Could not find parent navigation with route "/non-existent" is thrown.
NavigationContainerRefWithCurrent<RootParamList>The root <NavigationContainer /> ref for the app. The ref.current may be null
if the <NavigationContainer /> hasn't mounted yet.
Returns the currently selected route location without search parameters. For example, /acme?foo=bar returns /acme.
Segments will be normalized. For example, /[id]?id=normal becomes /normal.
stringExample
import { Text } from 'react-native'; import { usePathname } from 'expo-router'; export default function Route() { // pathname = "/profile/baconbrix" const pathname = usePathname(); return <Text>Pathname: {pathname}</Text>; }
Deprecated Use
useNavigationContainerRefinstead, which returns a Reactref.
NavigationContainerRef<RootParamList> | nullReturns the navigation state of the navigator which contains the current screen.
Readonly<undefined>Example
import { useRootNavigationState } from 'expo-router'; export default function Route() { const { routes } = useRootNavigationState(); return <Text>{routes[0].name}</Text>; }
Returns a list of selected file segments for the currently selected route. Segments are not normalized,
so they will be the same as the file path. For example, /[id]?id=normal becomes ["[id]"].
RouteSegments<TSegments>Example
import { Text } from 'react-native'; import { useSegments } from 'expo-router'; export default function Route() { // segments = ["profile", "[user]"] const segments = useSegments(); return <Text>Hello</Text>; }
useSegments can be typed using an abstract. Consider the following file structure:
- app - [user] - index.tsx - followers.tsx - settings.tsx
This can be strictly typed using the following abstract with useSegments hook:
const [first, second] = useSegments<['settings'] | ['[user]'] | ['[user]', 'followers']>()
SitemapType | nullMethods
| Parameter | Type |
|---|---|
| options | NativeStackNavigationOptions |
| props | StackScreenProps |
NativeStackNavigationOptionsElement| Parameter | Type | Description |
|---|---|---|
| Nav | T | The navigator component to wrap. |
| processor(optional) | (options: ScreenProps[]) => ScreenProps[] | A function that processes the screens before passing them to the navigator. |
| useOnlyUserDefinedScreens(optional) | boolean | If true, all screens not specified as navigator's children will be ignored. Default: false |
Returns a navigator that automatically injects matched routes and renders nothing when there are no children.
Return type with children prop optional.
Enables use of other built-in React Navigation navigators and other navigators built with the React Navigation custom navigator API.
Component<PropsWithoutRef<PickPartial<ComponentProps<T>, 'children'>>> & {
Protected: FunctionComponent<ProtectedProps>,
Screen: (props: ScreenProps<TOptions, TState, TEventMap>) => null
}Example
import { ParamListBase, TabNavigationState } from "@react-navigation/native"; import { createMaterialTopTabNavigator, MaterialTopTabNavigationOptions, MaterialTopTabNavigationEventMap, } from "@react-navigation/material-top-tabs"; import { withLayoutContext } from "expo-router"; const MaterialTopTabs = createMaterialTopTabNavigator(); const ExpoRouterMaterialTopTabs = withLayoutContext< MaterialTopTabNavigationOptions, typeof MaterialTopTabs.Navigator, TabNavigationState<ParamListBase>, MaterialTopTabNavigationEventMap >(MaterialTopTabs.Navigator); export default function TabLayout() { return <ExpoRouterMaterialTopTabs />; }
Interfaces
| Property | Type | Description |
|---|---|---|
| background_dark | ColorValue | PlatformColor("@android:color/background_dark") |
| background_light | ColorValue | PlatformColor("@android:color/background_light") |
| black | ColorValue | PlatformColor("@android:color/black") |
| darker_gray | ColorValue | PlatformColor("@android:color/darker_gray") |
| tab_indicator_text | ColorValue | PlatformColor("@android:color/tab_indicator_text") |
| transparent | ColorValue | PlatformColor("@android:color/transparent") |
| white | ColorValue | PlatformColor("@android:color/white") |
| widget_edittext_dark | ColorValue | PlatformColor("@android:color/widget_edittext_dark") |
| Property | Type | Description |
|---|---|---|
| holo_blue_bright | ColorValue | PlatformColor("@android:color/holo_blue_bright") |
| holo_blue_dark | ColorValue | PlatformColor("@android:color/holo_blue_dark") |
| holo_blue_light | ColorValue | PlatformColor("@android:color/holo_blue_light") |
| holo_green_dark | ColorValue | PlatformColor("@android:color/holo_green_dark") |
| holo_green_light | ColorValue | PlatformColor("@android:color/holo_green_light") |
| holo_orange_dark | ColorValue | PlatformColor("@android:color/holo_orange_dark") |
| holo_orange_light | ColorValue | PlatformColor("@android:color/holo_orange_light") |
| holo_purple | ColorValue | PlatformColor("@android:color/holo_purple") |
| holo_red_dark | ColorValue | PlatformColor("@android:color/holo_red_dark") |
| holo_red_light | ColorValue | PlatformColor("@android:color/holo_red_light") |
| Property | Type | Description |
|---|---|---|
| system_accent1_0 | ColorValue | PlatformColor("@android:color/system_accent1_0") |
| system_accent1_10 | ColorValue | PlatformColor("@android:color/system_accent1_10") |
| system_accent1_100 | ColorValue | PlatformColor("@android:color/system_accent1_100") |
| system_accent1_1000 | ColorValue | PlatformColor("@android:color/system_accent1_1000") |
| system_accent1_200 | ColorValue | PlatformColor("@android:color/system_accent1_200") |
| system_accent1_300 | ColorValue | PlatformColor("@android:color/system_accent1_300") |
| system_accent1_400 | ColorValue | PlatformColor("@android:color/system_accent1_400") |
| system_accent1_50 | ColorValue | PlatformColor("@android:color/system_accent1_50") |
| system_accent1_500 | ColorValue | PlatformColor("@android:color/system_accent1_500") |
| system_accent1_600 | ColorValue | PlatformColor("@android:color/system_accent1_600") |
| system_accent1_700 | ColorValue | PlatformColor("@android:color/system_accent1_700") |
| system_accent1_800 | ColorValue | PlatformColor("@android:color/system_accent1_800") |
| system_accent1_900 | ColorValue | PlatformColor("@android:color/system_accent1_900") |
| system_accent2_0 | ColorValue | PlatformColor("@android:color/system_accent2_0") |
| system_accent2_10 | ColorValue | PlatformColor("@android:color/system_accent2_10") |
| system_accent2_100 | ColorValue | PlatformColor("@android:color/system_accent2_100") |
| system_accent2_1000 | ColorValue | PlatformColor("@android:color/system_accent2_1000") |
| system_accent2_200 | ColorValue | PlatformColor("@android:color/system_accent2_200") |
| system_accent2_300 | ColorValue | PlatformColor("@android:color/system_accent2_300") |
| system_accent2_400 | ColorValue | PlatformColor("@android:color/system_accent2_400") |
| system_accent2_50 | ColorValue | PlatformColor("@android:color/system_accent2_50") |
| system_accent2_500 | ColorValue | PlatformColor("@android:color/system_accent2_500") |
| system_accent2_600 | ColorValue | PlatformColor("@android:color/system_accent2_600") |
| system_accent2_700 | ColorValue | PlatformColor("@android:color/system_accent2_700") |
| system_accent2_800 | ColorValue | PlatformColor("@android:color/system_accent2_800") |
| system_accent2_900 | ColorValue | PlatformColor("@android:color/system_accent2_900") |
| system_accent3_0 | ColorValue | PlatformColor("@android:color/system_accent3_0") |
| system_accent3_10 | ColorValue | PlatformColor("@android:color/system_accent3_10") |
| system_accent3_100 | ColorValue | PlatformColor("@android:color/system_accent3_100") |
| system_accent3_1000 | ColorValue | PlatformColor("@android:color/system_accent3_1000") |
| system_accent3_200 | ColorValue | PlatformColor("@android:color/system_accent3_200") |
| system_accent3_300 | ColorValue | PlatformColor("@android:color/system_accent3_300") |
| system_accent3_400 | ColorValue | PlatformColor("@android:color/system_accent3_400") |
| system_accent3_50 | ColorValue | PlatformColor("@android:color/system_accent3_50") |
| system_accent3_500 | ColorValue | PlatformColor("@android:color/system_accent3_500") |
| system_accent3_600 | ColorValue | PlatformColor("@android:color/system_accent3_600") |
| system_accent3_700 | ColorValue | PlatformColor("@android:color/system_accent3_700") |
| system_accent3_800 | ColorValue | PlatformColor("@android:color/system_accent3_800") |
| system_accent3_900 | ColorValue | PlatformColor("@android:color/system_accent3_900") |
| system_neutral1_0 | ColorValue | PlatformColor("@android:color/system_neutral1_0") |
| system_neutral1_10 | ColorValue | PlatformColor("@android:color/system_neutral1_10") |
| system_neutral1_100 | ColorValue | PlatformColor("@android:color/system_neutral1_100") |
| system_neutral1_1000 | ColorValue | PlatformColor("@android:color/system_neutral1_1000") |
| system_neutral1_200 | ColorValue | PlatformColor("@android:color/system_neutral1_200") |
| system_neutral1_300 | ColorValue | PlatformColor("@android:color/system_neutral1_300") |
| system_neutral1_400 | ColorValue | PlatformColor("@android:color/system_neutral1_400") |
| system_neutral1_50 | ColorValue | PlatformColor("@android:color/system_neutral1_50") |
| system_neutral1_500 | ColorValue | PlatformColor("@android:color/system_neutral1_500") |
| system_neutral1_600 | ColorValue | PlatformColor("@android:color/system_neutral1_600") |
| system_neutral1_700 | ColorValue | PlatformColor("@android:color/system_neutral1_700") |
| system_neutral1_800 | ColorValue | PlatformColor("@android:color/system_neutral1_800") |
| system_neutral1_900 | ColorValue | PlatformColor("@android:color/system_neutral1_900") |
| system_neutral2_0 | ColorValue | PlatformColor("@android:color/system_neutral2_0") |
| system_neutral2_10 | ColorValue | PlatformColor("@android:color/system_neutral2_10") |
| system_neutral2_100 | ColorValue | PlatformColor("@android:color/system_neutral2_100") |
| system_neutral2_1000 | ColorValue | PlatformColor("@android:color/system_neutral2_1000") |
| system_neutral2_200 | ColorValue | PlatformColor("@android:color/system_neutral2_200") |
| system_neutral2_300 | ColorValue | PlatformColor("@android:color/system_neutral2_300") |
| system_neutral2_400 | ColorValue | PlatformColor("@android:color/system_neutral2_400") |
| system_neutral2_50 | ColorValue | PlatformColor("@android:color/system_neutral2_50") |
| system_neutral2_500 | ColorValue | PlatformColor("@android:color/system_neutral2_500") |
| system_neutral2_600 | ColorValue | PlatformColor("@android:color/system_neutral2_600") |
| system_neutral2_700 | ColorValue | PlatformColor("@android:color/system_neutral2_700") |
| system_neutral2_800 | ColorValue | PlatformColor("@android:color/system_neutral2_800") |
| system_neutral2_900 | ColorValue | PlatformColor("@android:color/system_neutral2_900") |
| Property | Type | Description |
|---|---|---|
| system_background_dark | ColorValue | PlatformColor("@android:color/system_background_dark") |
| system_background_light | ColorValue | PlatformColor("@android:color/system_background_light") |
| system_control_activated_dark | ColorValue | PlatformColor("@android:color/system_control_activated_dark") |
| system_control_activated_light | ColorValue | PlatformColor("@android:color/system_control_activated_light") |
| system_control_highlight_dark | ColorValue | PlatformColor("@android:color/system_control_highlight_dark") |
| system_control_highlight_light | ColorValue | PlatformColor("@android:color/system_control_highlight_light") |
| system_control_normal_dark | ColorValue | PlatformColor("@android:color/system_control_normal_dark") |
| system_control_normal_light | ColorValue | PlatformColor("@android:color/system_control_normal_light") |
| system_error_container_dark | ColorValue | PlatformColor("@android:color/system_error_container_dark") |
| system_error_container_light | ColorValue | PlatformColor("@android:color/system_error_container_light") |
| system_error_dark | ColorValue | PlatformColor("@android:color/system_error_dark") |
| system_error_light | ColorValue | PlatformColor("@android:color/system_error_light") |
| system_on_background_dark | ColorValue | PlatformColor("@android:color/system_on_background_dark") |
| system_on_background_light | ColorValue | PlatformColor("@android:color/system_on_background_light") |
| system_on_error_container_dark | ColorValue | PlatformColor("@android:color/system_on_error_container_dark") |
| system_on_error_container_light | ColorValue | PlatformColor("@android:color/system_on_error_container_light") |
| system_on_error_dark | ColorValue | PlatformColor("@android:color/system_on_error_dark") |
| system_on_error_light | ColorValue | PlatformColor("@android:color/system_on_error_light") |
| system_on_primary_container_dark | ColorValue | PlatformColor("@android:color/system_on_primary_container_dark") |
| system_on_primary_container_light | ColorValue | PlatformColor("@android:color/system_on_primary_container_light") |
| system_on_primary_dark | ColorValue | PlatformColor("@android:color/system_on_primary_dark") |
| system_on_primary_fixed | ColorValue | PlatformColor("@android:color/system_on_primary_fixed") |
| system_on_primary_fixed_variant | ColorValue | PlatformColor("@android:color/system_on_primary_fixed_variant") |
| system_on_primary_light | ColorValue | PlatformColor("@android:color/system_on_primary_light") |
| system_on_secondary_container_dark | ColorValue | PlatformColor("@android:color/system_on_secondary_container_dark") |
| system_on_secondary_container_light | ColorValue | PlatformColor("@android:color/system_on_secondary_container_light") |
| system_on_secondary_dark | ColorValue | PlatformColor("@android:color/system_on_secondary_dark") |
| system_on_secondary_fixed | ColorValue | PlatformColor("@android:color/system_on_secondary_fixed") |
| system_on_secondary_fixed_variant | ColorValue | PlatformColor("@android:color/system_on_secondary_fixed_variant") |
| system_on_secondary_light | ColorValue | PlatformColor("@android:color/system_on_secondary_light") |
| system_on_surface_dark | ColorValue | PlatformColor("@android:color/system_on_surface_dark") |
| system_on_surface_light | ColorValue | PlatformColor("@android:color/system_on_surface_light") |
| system_on_surface_variant_dark | ColorValue | PlatformColor("@android:color/system_on_surface_variant_dark") |
| system_on_surface_variant_light | ColorValue | PlatformColor("@android:color/system_on_surface_variant_light") |
| system_on_tertiary_container_dark | ColorValue | PlatformColor("@android:color/system_on_tertiary_container_dark") |
| system_on_tertiary_container_light | ColorValue | PlatformColor("@android:color/system_on_tertiary_container_light") |
| system_on_tertiary_dark | ColorValue | PlatformColor("@android:color/system_on_tertiary_dark") |
| system_on_tertiary_fixed | ColorValue | PlatformColor("@android:color/system_on_tertiary_fixed") |
| system_on_tertiary_fixed_variant | ColorValue | PlatformColor("@android:color/system_on_tertiary_fixed_variant") |
| system_on_tertiary_light | ColorValue | PlatformColor("@android:color/system_on_tertiary_light") |
| system_outline_dark | ColorValue | PlatformColor("@android:color/system_outline_dark") |
| system_outline_light | ColorValue | PlatformColor("@android:color/system_outline_light") |
| system_outline_variant_dark | ColorValue | PlatformColor("@android:color/system_outline_variant_dark") |
| system_outline_variant_light | ColorValue | PlatformColor("@android:color/system_outline_variant_light") |
| system_palette_key_color_neutral_dark | ColorValue | PlatformColor("@android:color/system_palette_key_color_neutral_dark") |
| system_palette_key_color_neutral_light | ColorValue | PlatformColor("@android:color/system_palette_key_color_neutral_light") |
| system_palette_key_color_neutral_variant_dark | ColorValue | PlatformColor("@android:color/system_palette_key_color_neutral_variant_dark") |
| system_palette_key_color_neutral_variant_light | ColorValue | PlatformColor("@android:color/system_palette_key_color_neutral_variant_light") |
| system_palette_key_color_primary_dark | ColorValue | PlatformColor("@android:color/system_palette_key_color_primary_dark") |
| system_palette_key_color_primary_light | ColorValue | PlatformColor("@android:color/system_palette_key_color_primary_light") |
| system_palette_key_color_secondary_dark | ColorValue | PlatformColor("@android:color/system_palette_key_color_secondary_dark") |
| system_palette_key_color_secondary_light | ColorValue | PlatformColor("@android:color/system_palette_key_color_secondary_light") |
| system_palette_key_color_tertiary_dark | ColorValue | PlatformColor("@android:color/system_palette_key_color_tertiary_dark") |
| system_palette_key_color_tertiary_light | ColorValue | PlatformColor("@android:color/system_palette_key_color_tertiary_light") |
| system_primary_container_dark | ColorValue | PlatformColor("@android:color/system_primary_container_dark") |
| system_primary_container_light | ColorValue | PlatformColor("@android:color/system_primary_container_light") |
| system_primary_dark | ColorValue | PlatformColor("@android:color/system_primary_dark") |
| system_primary_fixed | ColorValue | PlatformColor("@android:color/system_primary_fixed") |
| system_primary_fixed_dim | ColorValue | PlatformColor("@android:color/system_primary_fixed_dim") |
| system_primary_light | ColorValue | PlatformColor("@android:color/system_primary_light") |
| system_secondary_container_dark | ColorValue | PlatformColor("@android:color/system_secondary_container_dark") |
| system_secondary_container_light | ColorValue | PlatformColor("@android:color/system_secondary_container_light") |
| system_secondary_dark | ColorValue | PlatformColor("@android:color/system_secondary_dark") |
| system_secondary_fixed | ColorValue | PlatformColor("@android:color/system_secondary_fixed") |
| system_secondary_fixed_dim | ColorValue | PlatformColor("@android:color/system_secondary_fixed_dim") |
| system_secondary_light | ColorValue | PlatformColor("@android:color/system_secondary_light") |
| system_surface_bright_dark | ColorValue | PlatformColor("@android:color/system_surface_bright_dark") |
| system_surface_bright_light | ColorValue | PlatformColor("@android:color/system_surface_bright_light") |
| system_surface_container_dark | ColorValue | PlatformColor("@android:color/system_surface_container_dark") |
| system_surface_container_high_dark | ColorValue | PlatformColor("@android:color/system_surface_container_high_dark") |
| system_surface_container_high_light | ColorValue | PlatformColor("@android:color/system_surface_container_high_light") |
| system_surface_container_highest_dark | ColorValue | PlatformColor("@android:color/system_surface_container_highest_dark") |
| system_surface_container_highest_light | ColorValue | PlatformColor("@android:color/system_surface_container_highest_light") |
| system_surface_container_light | ColorValue | PlatformColor("@android:color/system_surface_container_light") |
| system_surface_container_low_dark | ColorValue | PlatformColor("@android:color/system_surface_container_low_dark") |
| system_surface_container_low_light | ColorValue | PlatformColor("@android:color/system_surface_container_low_light") |
| system_surface_container_lowest_dark | ColorValue | PlatformColor("@android:color/system_surface_container_lowest_dark") |
| system_surface_container_lowest_light | ColorValue | PlatformColor("@android:color/system_surface_container_lowest_light") |
| system_surface_dark | ColorValue | PlatformColor("@android:color/system_surface_dark") |
| system_surface_dim_dark | ColorValue | PlatformColor("@android:color/system_surface_dim_dark") |
| system_surface_dim_light | ColorValue | PlatformColor("@android:color/system_surface_dim_light") |
| system_surface_light | ColorValue | PlatformColor("@android:color/system_surface_light") |
| system_surface_variant_dark | ColorValue | PlatformColor("@android:color/system_surface_variant_dark") |
| system_surface_variant_light | ColorValue | PlatformColor("@android:color/system_surface_variant_light") |
| system_tertiary_container_dark | ColorValue | PlatformColor("@android:color/system_tertiary_container_dark") |
| system_tertiary_container_light | ColorValue | PlatformColor("@android:color/system_tertiary_container_light") |
| system_tertiary_dark | ColorValue | PlatformColor("@android:color/system_tertiary_dark") |
| system_tertiary_fixed | ColorValue | PlatformColor("@android:color/system_tertiary_fixed") |
| system_tertiary_fixed_dim | ColorValue | PlatformColor("@android:color/system_tertiary_fixed_dim") |
| system_tertiary_light | ColorValue | PlatformColor("@android:color/system_tertiary_light") |
| system_text_hint_inverse_dark | ColorValue | PlatformColor("@android:color/system_text_hint_inverse_dark") |
| system_text_hint_inverse_light | ColorValue | PlatformColor("@android:color/system_text_hint_inverse_light") |
| system_text_primary_inverse_dark | ColorValue | PlatformColor("@android:color/system_text_primary_inverse_dark") |
| system_text_primary_inverse_disable_only_dark | ColorValue | PlatformColor("@android:color/system_text_primary_inverse_disable_only_dark") |
| system_text_primary_inverse_disable_only_light | ColorValue | PlatformColor("@android:color/system_text_primary_inverse_disable_only_light") |
| system_text_primary_inverse_light | ColorValue | PlatformColor("@android:color/system_text_primary_inverse_light") |
| system_text_secondary_and_tertiary_inverse_dark | ColorValue | PlatformColor("@android:color/system_text_secondary_and_tertiary_inverse_dark") |
| system_text_secondary_and_tertiary_inverse_disabled_dark | ColorValue | PlatformColor("@android:color/system_text_secondary_and_tertiary_inverse_disabled_dark") |
| system_text_secondary_and_tertiary_inverse_disabled_light | ColorValue | PlatformColor("@android:color/system_text_secondary_and_tertiary_inverse_disabled_light") |
| system_text_secondary_and_tertiary_inverse_light | ColorValue | PlatformColor("@android:color/system_text_secondary_and_tertiary_inverse_light") |
| Property | Type | Description |
|---|---|---|
| system_error_0 | ColorValue | PlatformColor("@android:color/system_error_0") |
| system_error_10 | ColorValue | PlatformColor("@android:color/system_error_10") |
| system_error_100 | ColorValue | PlatformColor("@android:color/system_error_100") |
| system_error_1000 | ColorValue | PlatformColor("@android:color/system_error_1000") |
| system_error_200 | ColorValue | PlatformColor("@android:color/system_error_200") |
| system_error_300 | ColorValue | PlatformColor("@android:color/system_error_300") |
| system_error_400 | ColorValue | PlatformColor("@android:color/system_error_400") |
| system_error_50 | ColorValue | PlatformColor("@android:color/system_error_50") |
| system_error_500 | ColorValue | PlatformColor("@android:color/system_error_500") |
| system_error_600 | ColorValue | PlatformColor("@android:color/system_error_600") |
| system_error_700 | ColorValue | PlatformColor("@android:color/system_error_700") |
| system_error_800 | ColorValue | PlatformColor("@android:color/system_error_800") |
| system_error_900 | ColorValue | PlatformColor("@android:color/system_error_900") |
| system_on_surface_disabled | ColorValue | PlatformColor("@android:color/system_on_surface_disabled") |
| system_outline_disabled | ColorValue | PlatformColor("@android:color/system_outline_disabled") |
| system_surface_disabled | ColorValue | PlatformColor("@android:color/system_surface_disabled") |
| Property | Type | Description |
|---|---|---|
| colorBackground | ColorValue | PlatformColor("?attr/colorBackground") |
| colorForeground | ColorValue | PlatformColor("?attr/colorForeground") |
| colorForegroundInverse | ColorValue | PlatformColor("?attr/colorForegroundInverse") |
| Property | Type | Description |
|---|---|---|
| colorActivatedHighlight | ColorValue | PlatformColor("?attr/colorActivatedHighlight") |
| colorFocusedHighlight | ColorValue | PlatformColor("?attr/colorFocusedHighlight") |
| colorLongPressedHighlight | ColorValue | PlatformColor("?attr/colorLongPressedHighlight") |
| colorMultiSelectHighlight | ColorValue | PlatformColor("?attr/colorMultiSelectHighlight") |
| colorPressedHighlight | ColorValue | PlatformColor("?attr/colorPressedHighlight") |
| Property | Type | Description |
|---|---|---|
| colorAccent | ColorValue | PlatformColor("?attr/colorAccent") |
| colorButtonNormal | ColorValue | PlatformColor("?attr/colorButtonNormal") |
| colorControlActivated | ColorValue | PlatformColor("?attr/colorControlActivated") |
| colorControlHighlight | ColorValue | PlatformColor("?attr/colorControlHighlight") |
| colorControlNormal | ColorValue | PlatformColor("?attr/colorControlNormal") |
| colorEdgeEffect | ColorValue | PlatformColor("?attr/colorEdgeEffect") |
| colorPrimary | ColorValue | PlatformColor("?attr/colorPrimary") |
| colorPrimaryDark | ColorValue | PlatformColor("?attr/colorPrimaryDark") |
| Property | Type | Description |
|---|---|---|
| colorBackgroundFloating | ColorValue | PlatformColor("?attr/colorBackgroundFloating") |
| Property | Type | Description |
|---|---|---|
| colorSecondary | ColorValue | PlatformColor("?attr/colorSecondary") |
| Property | Type | Description |
|---|---|---|
| colorError | ColorValue | PlatformColor("?attr/colorError") |
| colorMode | ColorValue | PlatformColor("?attr/colorMode") |
| Property | Type | Description |
|---|---|---|
| colorBackgroundCacheHint | ColorValue | PlatformColor("?attr/colorBackgroundCacheHint") |
| Property | Type | Description |
|---|---|---|
| primary_text_dark | ColorValue |
PlatformColor("@android:color/primary_text_dark") |
| primary_text_dark_nodisable | ColorValue |
PlatformColor("@android:color/primary_text_dark_nodisable") |
| primary_text_light | ColorValue |
PlatformColor("@android:color/primary_text_light") |
| primary_text_light_nodisable | ColorValue |
PlatformColor("@android:color/primary_text_light_nodisable") |
| secondary_text_dark | ColorValue |
PlatformColor("@android:color/secondary_text_dark") |
| secondary_text_dark_nodisable | ColorValue |
PlatformColor("@android:color/secondary_text_dark_nodisable") |
| secondary_text_light | ColorValue |
PlatformColor("@android:color/secondary_text_light") |
| secondary_text_light_nodisable | ColorValue |
PlatformColor("@android:color/secondary_text_light_nodisable") |
| tertiary_text_dark | ColorValue |
PlatformColor("@android:color/tertiary_text_dark") |
| tertiary_text_light | ColorValue |
PlatformColor("@android:color/tertiary_text_light") |
Android Dynamic Material Colors
You can find out more about color roles in official Material Design 3 documentation.
You can read about the difference between dynamic and static colors in official Material Design 3 documentation.
For a detailed definition of each color role, see material components color documentation.
| Property | Type | Description |
|---|---|---|
| background | ColorValue | Android Dynamic Material Colors This color adapts based on the user's wallpaper and theme settings. |
| error | ColorValue | Android Dynamic Material Colors This color adapts based on the user's wallpaper and theme settings. |
| errorContainer | ColorValue | Android Dynamic Material Colors This color adapts based on the user's wallpaper and theme settings. |
| onBackground | ColorValue | Android Dynamic Material Colors This color adapts based on the user's wallpaper and theme settings. |
| onError | ColorValue | Android Dynamic Material Colors This color adapts based on the user's wallpaper and theme settings. |
| onErrorContainer | ColorValue | Android Dynamic Material Colors This color adapts based on the user's wallpaper and theme settings. |
| onPrimary | ColorValue | Android Dynamic Material Colors This color adapts based on the user's wallpaper and theme settings. |
| onPrimaryContainer | ColorValue | Android Dynamic Material Colors This color adapts based on the user's wallpaper and theme settings. |
| onPrimaryFixed | ColorValue | Android Dynamic Material Colors This color adapts based on the user's wallpaper and theme settings. |
| onPrimaryFixedVariant | ColorValue | Android Dynamic Material Colors This color adapts based on the user's wallpaper and theme settings. |
| onSecondary | ColorValue | Android Dynamic Material Colors This color adapts based on the user's wallpaper and theme settings. |
| onSecondaryContainer | ColorValue | Android Dynamic Material Colors This color adapts based on the user's wallpaper and theme settings. |
| onSecondaryFixed | ColorValue | Android Dynamic Material Colors This color adapts based on the user's wallpaper and theme settings. |
| onSecondaryFixedVariant | ColorValue | Android Dynamic Material Colors This color adapts based on the user's wallpaper and theme settings. |
| onSurface | ColorValue | Android Dynamic Material Colors This color adapts based on the user's wallpaper and theme settings. |
| onSurfaceInverse | ColorValue | Android Dynamic Material Colors This color adapts based on the user's wallpaper and theme settings. |
| onSurfaceVariant | ColorValue | Android Dynamic Material Colors This color adapts based on the user's wallpaper and theme settings. |
| onTertiary | ColorValue | Android Dynamic Material Colors This color adapts based on the user's wallpaper and theme settings. |
| onTertiaryContainer | ColorValue | Android Dynamic Material Colors This color adapts based on the user's wallpaper and theme settings. |
| onTertiaryFixed | ColorValue | Android Dynamic Material Colors This color adapts based on the user's wallpaper and theme settings. |
| onTertiaryFixedVariant | ColorValue | Android Dynamic Material Colors This color adapts based on the user's wallpaper and theme settings. |
| outline | ColorValue | Android Dynamic Material Colors This color adapts based on the user's wallpaper and theme settings. |
| outlineVariant | ColorValue | Android Dynamic Material Colors This color adapts based on the user's wallpaper and theme settings. |
| primary | ColorValue | Android Dynamic Material Colors This color adapts based on the user's wallpaper and theme settings. |
| primaryContainer | ColorValue | Android Dynamic Material Colors This color adapts based on the user's wallpaper and theme settings. |
| primaryFixed | ColorValue | Android Dynamic Material Colors This color adapts based on the user's wallpaper and theme settings. |
| primaryFixedDim | ColorValue | Android Dynamic Material Colors This color adapts based on the user's wallpaper and theme settings. |
| primaryInverse | ColorValue | Android Dynamic Material Colors This color adapts based on the user's wallpaper and theme settings. |
| secondary | ColorValue | Android Dynamic Material Colors This color adapts based on the user's wallpaper and theme settings. |
| secondaryContainer | ColorValue | Android Dynamic Material Colors This color adapts based on the user's wallpaper and theme settings. |
| secondaryFixed | ColorValue | Android Dynamic Material Colors This color adapts based on the user's wallpaper and theme settings. |
| secondaryFixedDim | ColorValue | Android Dynamic Material Colors This color adapts based on the user's wallpaper and theme settings. |
| surface | ColorValue | Android Dynamic Material Colors This color adapts based on the user's wallpaper and theme settings. |
| surfaceBright | ColorValue | Android Dynamic Material Colors This color adapts based on the user's wallpaper and theme settings. |
| surfaceContainer | ColorValue | Android Dynamic Material Colors This color adapts based on the user's wallpaper and theme settings. |
| surfaceContainerHigh | ColorValue | Android Dynamic Material Colors This color adapts based on the user's wallpaper and theme settings. |
| surfaceContainerHighest | ColorValue | Android Dynamic Material Colors This color adapts based on the user's wallpaper and theme settings. |
| surfaceContainerLow | ColorValue | Android Dynamic Material Colors This color adapts based on the user's wallpaper and theme settings. |
| surfaceContainerLowest | ColorValue | Android Dynamic Material Colors This color adapts based on the user's wallpaper and theme settings. |
| surfaceDim | ColorValue | Android Dynamic Material Colors This color adapts based on the user's wallpaper and theme settings. |
| surfaceInverse | ColorValue | Android Dynamic Material Colors This color adapts based on the user's wallpaper and theme settings. |
| surfaceVariant | ColorValue | Android Dynamic Material Colors This color adapts based on the user's wallpaper and theme settings. |
| tertiary | ColorValue | Android Dynamic Material Colors This color adapts based on the user's wallpaper and theme settings. |
| tertiaryContainer | ColorValue | Android Dynamic Material Colors This color adapts based on the user's wallpaper and theme settings. |
| tertiaryFixed | ColorValue | Android Dynamic Material Colors This color adapts based on the user's wallpaper and theme settings. |
| tertiaryFixedDim | ColorValue | Android Dynamic Material Colors This color adapts based on the user's wallpaper and theme settings. |
Android Static Material Colors
You can find out more about color roles in official Material Design 3 documentation.
You can read about the difference between dynamic and static colors in official Material Design 3 documentation.
For a detailed definition of each color role, see material components color documentation.
| Property | Type | Description |
|---|---|---|
| background | ColorValue | |
| error | ColorValue | |
| errorContainer | ColorValue | |
| onBackground | ColorValue | |
| onError | ColorValue | |
| onErrorContainer | ColorValue | |
| onPrimary | ColorValue | |
| onPrimaryContainer | ColorValue | |
| onPrimaryFixed | ColorValue | |
| onPrimaryFixedVariant | ColorValue | |
| onSecondary | ColorValue | |
| onSecondaryContainer | ColorValue | |
| onSecondaryFixed | ColorValue | |
| onSecondaryFixedVariant | ColorValue | |
| onSurface | ColorValue | |
| onSurfaceInverse | ColorValue | |
| onSurfaceVariant | ColorValue | |
| onTertiary | ColorValue | |
| onTertiaryContainer | ColorValue | |
| onTertiaryFixed | ColorValue | |
| onTertiaryFixedVariant | ColorValue | |
| outline | ColorValue | |
| outlineVariant | ColorValue | |
| primary | ColorValue | |
| primaryContainer | ColorValue | |
| primaryFixed | ColorValue | |
| primaryFixedDim | ColorValue | |
| primaryInverse | ColorValue | |
| secondary | ColorValue | |
| secondaryContainer | ColorValue | |
| secondaryFixed | ColorValue | |
| secondaryFixedDim | ColorValue | |
| surface | ColorValue | |
| surfaceBright | ColorValue | |
| surfaceContainer | ColorValue | |
| surfaceContainerHigh | ColorValue | |
| surfaceContainerHighest | ColorValue | |
| surfaceContainerLow | ColorValue | |
| surfaceContainerLowest | ColorValue | |
| surfaceDim | ColorValue | |
| surfaceInverse | ColorValue | |
| surfaceVariant | ColorValue | |
| tertiary | ColorValue | |
| tertiaryContainer | ColorValue | |
| tertiaryFixed | ColorValue | |
| tertiaryFixedDim | ColorValue |
| Property | Type | Description |
|---|---|---|
| android | AndroidBaseColorSDK1 & AndroidBaseColorSDK14 & AndroidBaseColorSDK31 & AndroidBaseColorSDK34 & AndroidBaseColorSDK35 & AndroidDeprecatedColor & undefined & {
attr: AndroidBaseColorAttr,
dynamic: AndroidDynamicMaterialColor,
material: AndroidMaterialColor
} | - |
| ios | IOSBaseColor & undefined | - |
| Property | Type | Description |
|---|---|---|
| darkText | ColorValue | PlatformColor("darkText") |
| label | ColorValue | PlatformColor("label") |
| lightText | ColorValue | PlatformColor("lightText") |
| link | ColorValue | PlatformColor("link") |
| opaqueSeparator | ColorValue | PlatformColor("opaqueSeparator") |
| placeholderText | ColorValue | PlatformColor("placeholderText") |
| quaternaryLabel | ColorValue | PlatformColor("quaternaryLabel") |
| quaternarySystemFill | ColorValue | PlatformColor("quaternarySystemFill") |
| secondaryLabel | ColorValue | PlatformColor("secondaryLabel") |
| secondarySystemBackground | ColorValue | PlatformColor("secondarySystemBackground") |
| secondarySystemFill | ColorValue | PlatformColor("secondarySystemFill") |
| secondarySystemGroupedBackground | ColorValue | PlatformColor("secondarySystemGroupedBackground") |
| separator | ColorValue | PlatformColor("separator") |
| systemBackground | ColorValue | PlatformColor("systemBackground") |
| systemBlue | ColorValue | PlatformColor("systemBlue") |
| systemBrown | ColorValue | PlatformColor("systemBrown") |
| systemCyan | ColorValue | PlatformColor("systemCyan") |
| systemFill | ColorValue | PlatformColor("systemFill") |
| systemGray | ColorValue | PlatformColor("systemGray") |
| systemGray2 | ColorValue | PlatformColor("systemGray2") |
| systemGray3 | ColorValue | PlatformColor("systemGray3") |
| systemGray4 | ColorValue | PlatformColor("systemGray4") |
| systemGray5 | ColorValue | PlatformColor("systemGray5") |
| systemGray6 | ColorValue | PlatformColor("systemGray6") |
| systemGreen | ColorValue | PlatformColor("systemGreen") |
| systemGroupedBackground | ColorValue | PlatformColor("systemGroupedBackground") |
| systemIndigo | ColorValue | PlatformColor("systemIndigo") |
| systemMint | ColorValue | PlatformColor("systemMint") |
| systemOrange | ColorValue | PlatformColor("systemOrange") |
| systemPink | ColorValue | PlatformColor("systemPink") |
| systemPurple | ColorValue | PlatformColor("systemPurple") |
| systemRed | ColorValue | PlatformColor("systemRed") |
| systemTeal | ColorValue | PlatformColor("systemTeal") |
| systemYellow | ColorValue | PlatformColor("systemYellow") |
| tertiaryLabel | ColorValue | PlatformColor("tertiaryLabel") |
| tertiarySystemBackground | ColorValue | PlatformColor("tertiarySystemBackground") |
| tertiarySystemFill | ColorValue | PlatformColor("tertiarySystemFill") |
| tertiarySystemGroupedBackground | ColorValue | PlatformColor("tertiarySystemGroupedBackground") |
| Property | Type | Description |
|---|---|---|
| accessibilityHint(optional) | string | - |
| accessibilityLabel(optional) | string | - |
| children(optional) | ReactNode | - |
| disabled(optional) | boolean | - |
| hidesSharedBackground(optional) | boolean | - |
| icon(optional) | ImageSourcePropType | SFSymbols6_0 | - |
| separateBackground(optional) | boolean | - |
| style(optional) | StyleProp<BasicTextStyle> | - |
| tintColor(optional) | ColorValue | - |
| variant(optional) | 'done' | 'plain' | 'prominent' | Default: 'plain' |
Types
Type: AndroidBaseColorSDK1 AndroidBaseColorSDK14 AndroidBaseColorSDK31 AndroidBaseColorSDK34 AndroidBaseColorSDK35 AndroidDeprecatedColor extended by:
| Property | Type | Description |
|---|
Type: AndroidColorAttrSDK1 AndroidColorAttrSDK5 AndroidColorAttrSDK14 AndroidColorAttrSDK21 AndroidColorAttrSDK23 AndroidColorAttrSDK25 AndroidColorAttrSDK26 extended by:
| Property | Type | Description |
|---|
Type: AndroidDynamicMaterialColorType extended by:
| Property | Type | Description |
|---|
Type: AndroidStaticMaterialColorType extended by:
| Property | Type | Description |
|---|
Memoized callback containing the effect, should optionally return a cleanup function.
undefined | void | () => void
Literal Type: union
Acceptable values are: {string}:{string} | //{string}
The main routing type for Expo Router. It includes all available routes with strongly typed parameters. It can either be:
- string: A full path like
/profile/settingsor a relative path like../settings. - object: An object with a
pathnameand optionalparams. Thepathnamecan be a full path like/profile/settingsor a relative path like../settings. The params can be an object of key-value pairs.
An Href can either be a string or an object.
Generic: T
Type: T ? T[href] : string | HrefObject
| Property | Type | Description |
|---|---|---|
| params(optional) | UnknownInputParams | Optional parameters for the route. |
| pathname | string | The path of the route. |
Type: Omit<ViewStyle, 'position' | 'width' | 'height'> extended by:
| Property | Type | Description |
|---|---|---|
| height(optional) | number | Sets the preferred height of the preview. If not set, full height of the screen will be used. This is only preferred height, the actual height may be different |
| width(optional) | number | Sets the preferred width of the preview. If not set, full width of the screen will be used. This is only preferred width, the actual width may be different |
Function type for route loaders. Loaders are executed on the server during SSR/SSG to fetch data required by a route.
| Parameter | Type |
|---|---|
| args | {
params: Record<string, string | string[]>,
request: Request
} |
Promise<T> | T
Created by using a special file called +native-intent.tsx at the top-level of your
project's app directory. It exports redirectSystemPath or legacy_subscribe functions,
both methods designed to handle URL/path processing.
Useful for re-writing URLs to correctly target a route when unique/referred URLs are incoming from third-party providers or stale URLs from previous versions.
See: For more information on how to use
NativeIntent, see Customizing links.
| Property | Type | Description |
|---|---|---|
| legacy_subscribe(optional) | (listener: (url: string) => void) => undefined | void | () => void |
Useful as an alternative API when a third-party provider doesn't support Expo Router
but has support for React Navigation via Using this API is not recommended for newer projects or integrations since it is incompatible with Server Side Routing and Static Rendering, and can become challenging to manage while offline or in a low network environment. |
| redirectSystemPath(optional) | (event: {
initial: boolean,
path: string
}) => Promise<string | null> | string | null | A special method used to process URLs in native apps. When invoked, it receives an
Its return value should be a Note that throwing errors within this method may result in app crashes. It's recommended to
wrap your code inside a
|
Literal Type: union
The list of input keys will become optional, everything else will remain the same.
| Property | Type | Description |
|---|---|---|
| destination | string | - |
| destinationContextKey | string | - |
| external(optional) | boolean | - |
| methods(optional) | string[] | - |
| permanent(optional) | boolean | - |
| source | string | - |
Literal Type: union
Acceptable values are: ./{string} | ../{string} | '..'
Type: PartialState<NavigationState> extended by:
| Property | Type | Description |
|---|---|---|
| state(optional) | ResultState | - |
Type: Exclude<Extract[pathname], RelativePathString | ExternalPathString>
Returns router object for imperative navigation API.
Example
import { router } from 'expo-router'; import { Text } from 'react-native'; export default function Route() { return ( <Text onPress={() => router.push('/home')}>Go Home</Text> ); }
| Property | Type | Description |
|---|---|---|
| back | () => void | Goes back in the navigation history. |
| canDismiss | () => boolean | Checks if it is possible to dismiss the current screen. Returns |
| canGoBack | () => boolean | Navigates to a route in the navigator's history if it supports invoking the |
| dismiss | (count: number) => void | Navigates to the a stack lower than the current screen using the provided count if possible, otherwise 1. If the current screen is the only route, it will dismiss the entire stack. |
| dismissAll | () => void | Returns to the first screen in the closest stack. This is similar to
|
| dismissTo | (href: Href, options: NavigationOptions) => void | Dismisses screens until the provided href is reached. If the href is not found, it will instead replace the current screen with the provided |
| navigate | (href: Href, options: NavigationOptions) => void | Navigates to the provided |
| prefetch | (name: Href) => void | Prefetch a screen in the background before navigating to it |
| push | (href: Href, options: NavigationOptions) => void | Navigates to the provided |
| replace | (href: Href, options: NavigationOptions) => void | Navigates to route without appending to the history. Can be used with
|
| setParams | (params: Partial<RouteInputParams<T>>) => void | Updates the current route's query params. |
| Property | Type | Description |
|---|---|---|
| dangerouslySingular(optional) | SingularOptions | - |
| getId(optional) | ({ params }: {
params: Record<string, any>
}) => string | undefined | - |
| initialParams(optional) | Record<string, any> | - |
| listeners(optional) | ScreenListeners<TState, TEventMap> | (prop: {
navigation: any,
route: RouteProp<ParamListBase, string>
}) => ScreenListeners<TState, TEventMap> | - |
| name(optional) | string | Name is required when used inside a Layout component. |
| options(optional) | TOptions | (prop: {
navigation: any,
route: RouteProp<ParamListBase, string>
}) => TOptions | - |
| redirect(optional) | boolean | Redirect to the nearest sibling route.
If all children are |
Type: boolean or object shaped as below:
(name, params) => string | undefined
string | undefined| Parameter | Type | Description |
|---|---|---|
| name(index signature) | string | - |
| params(index signature) | UnknownOutputParams | - |
| Property | Type | Description |
|---|---|---|
| children | SitemapType[] | - |
| contextKey | string | - |
| filename | string | - |
| href | string | Href | - |
| isGenerated | boolean | - |
| isInitial | boolean | - |
| isInternal | boolean | - |
| Property | Type | Description |
|---|---|---|
| download(optional) | string | Specifies that the The value of the Example
|
| rel(optional) | string | Specifies the relationship between the Common values:
The This property is passed to the underlying anchor ( Example
|
| target(optional) | '_self' | '_blank' | '_parent' | '_top' | string & object | Specifies where to open the
This property is passed to the underlying anchor ( Default: '_self'Example
|