React Native · Components
Navigator
The app's navigation: stack (pages sliding in from the right, modals from the bottom), tabs, nested stacks, swipe back, the Android back button, deep links.
Import
Header
componentThe default header bar: a back (close in a modal) button, the title and right-side items. It leaves the safe area's top inset itself. You can use it too when drawing your own bar with the header option.
TabBar
componentThe default tab bar: icon, label and badge. Leaves the safe area's bottom inset.
HEADER_HEIGHT
constantHeight of the header bar (excluding the safe area, before scaling).
useRoute
functionThe screen's route: name and params. The params also arrive as the screen component's params prop.
useIsFocused
functionWhether the screen is focused (the top page and the selected tab).
useFocusEffect
functionRuns when the screen gains focus and cleans up when it loses focus (data refresh, listeners, timers). You can wrap the function in useCallback; it re-runs when it changes.
Examples
usePreventRemove
functionPrevents the screen from closing (back button, swipe back, back, returning to another route); for unsaved changes. When blocked onPrevent is called; event.proceed() applies the operation anyway.
Examples
createRoutes
functionDefines the route map (an identity function for type inference). Names must be unique, nested ones included.
Examples
NAVIGATION_TEXTS
constantTexts of navigation components (accessibility labels).
RouteInfo
interfaceRoute info of a screen.
| Name | Type | Description |
|---|---|---|
key | string | Unique key. |
name | string | Route name. |
params | P | Params. |
LinkingOptions
interfaceDeep link settings.
| Name | Type | Description |
|---|---|---|
prefixes | string[] | The app's link prefixes: "myapp://", "https://site.com". |
enabled? | boolean | false: links are not listened to. |
onUnhandled? | (url: string) => void | A link with no match (e.g. open it in the browser). |
StackAnimation
typeEnter animation of a new screen in the stack.
Presentation
typePresentation of a screen.
TabAnimation
typeTab transition animation.
TabBackBehavior
typeBehavior of the back button in tabs.
OptionsContext
interfaceInfo passed to option functions.
| Name | Type | Description |
|---|---|---|
params | P | Params of the screen. |
Dynamic
typeA value, or a function producing a value from the params.
HeaderItemProps
interfaceInfo passed to elements drawn in the header bar.
| Name | Type | Description |
|---|---|---|
tintColor | string | Foreground color. |
canGoBack | boolean | Whether it can go back. |
TabIconProps
interfaceInfo given to the tab icon.
| Name | Type | Description |
|---|---|---|
focused | boolean | Whether the tab is selected. |
color | string | Selected/unselected color. |
size | number | Suggested size. |
RouteOptions
interfaceOptions of a screen (or a container).
| Name | Type | Description |
|---|---|---|
title? | Dynamic<string, P> | Title (header bar and tab label). |
headerShown? | Dynamic<boolean, P> | Whether the header bar is shown. Defaults to true for screens and false for containers (tabs/stack). |
headerTitleAlign? | "center" | "left" | Title alignment. Defaults to "center" (the same on both platforms). |
headerTransparent? | boolean | The header bar sits transparent over the content (content starts below it). |
headerTitle? | (props: HeaderItemProps & { title: string; }) => ReactNode | Drawn in place of the title. |
headerLeft? | (props: HeaderItemProps) => ReactNode | Drawn on the left (in place of the back button). |
headerRight? | (props: HeaderItemProps) => ReactNode | Drawn on the right (action buttons). |
header? | (props: HeaderProps) => ReactNode | Drawn in place of the whole header bar. |
presentation? | Presentation | Presentation. Defaults to "card". |
animation? | StackAnimation | Enter animation; defaults by presentation (card → slide, modal → slideUp). |
animationDuration? | number | Animation duration (ms). |
gestureEnabled? | boolean | Swipe back (left to right on a card, top to bottom on a modal). Defaults to true. |
fullScreenGestureEnabled? | boolean | The swipe can start anywhere on the screen (not only from the left edge). |
backgroundColor? | string | Background color of the screen; defaults to the theme's background color. |
icon? | IconProp | ((props: TabIconProps) => ReactNode) | Tab icon: an icon name/data or a render function. |
badge? | Dynamic<number | string | boolean | undefined, P> | Tab badge: a number, text or true (a dot). |
tabLabel? | string | Tab label (title if omitted). |
HeaderProps
interfaceInfo passed to the header bar.
| Name | Type | Description |
|---|---|---|
title | string | The resolved title. |
options | ResolvedOptions | The resolved options. |
canGoBack | boolean | Whether the back button is shown. |
onBack | () => void | Back (or close in a modal). |
ScreenProps
interfaceProps passed to screen components.
| Name | Type | Description |
|---|---|---|
params | P | Params of the screen. |
ScreenDef
interfaceA screen definition.
| Name | Type | Description |
|---|---|---|
screen | ComponentType<ScreenProps<P>> | ComponentType<Record<string, never>> | Screen component; the params type is inferred from the component's params prop. |
path? | string | Deep link path: "product/:id", an optional segment ":tab?". The query string (?ref=mail) is added to the params. |
initialParams? | Partial<P> | Used when no params are given. |
title? | Dynamic<string, P> | Title (header bar and tab label). |
headerShown? | Dynamic<boolean, P> | Whether the header bar is shown. Defaults to true for screens and false for containers (tabs/stack). |
headerTitleAlign? | "center" | "left" | Title alignment. Defaults to "center" (the same on both platforms). |
headerTransparent? | boolean | The header bar sits transparent over the content (content starts below it). |
headerTitle? | (props: HeaderItemProps & { title: string; }) => ReactNode | Drawn in place of the title. |
headerLeft? | (props: HeaderItemProps) => ReactNode | Drawn on the left (in place of the back button). |
headerRight? | (props: HeaderItemProps) => ReactNode | Drawn on the right (action buttons). |
header? | (props: HeaderProps) => ReactNode | Drawn in place of the whole header bar. |
presentation? | Presentation | Presentation. Defaults to "card". |
animation? | StackAnimation | Enter animation; defaults by presentation (card → slide, modal → slideUp). |
animationDuration? | number | Animation duration (ms). |
gestureEnabled? | boolean | Swipe back (left to right on a card, top to bottom on a modal). Defaults to true. |
fullScreenGestureEnabled? | boolean | The swipe can start anywhere on the screen (not only from the left edge). |
backgroundColor? | string | Background color of the screen; defaults to the theme's background color. |
icon? | IconProp | ((props: TabIconProps) => ReactNode) | Tab icon: an icon name/data or a render function. |
badge? | Dynamic<number | string | boolean | undefined, P> | Tab badge: a number, text or true (a dot). |
tabLabel? | string | Tab label (title if omitted). |
TabsDef
interfaceA tabbed container definition.
| Name | Type | Description |
|---|---|---|
tabs | RouteMap | Tabs (in order). Each can be a screen or a container. |
initialRoute? | string | Tab opened first; defaults to the first tab. |
tabAnimation? | TabAnimation | Tab transition animation. Defaults to "fade". |
backBehavior? | TabBackBehavior | Back button behavior. Defaults to "history". |
lazy? | boolean | Whether tab screens are created on first open (default true) or all up front. |
hideTabBarOnKeyboard? | boolean | Hide the tab bar while the keyboard is open. Defaults to true. |
tabBar? | (props: TabBarProps) => ReactNode | Drawn in place of the tab bar. |
title? | Dynamic<string, P> | Title (header bar and tab label). |
headerShown? | Dynamic<boolean, P> | Whether the header bar is shown. Defaults to true for screens and false for containers (tabs/stack). |
headerTitleAlign? | "center" | "left" | Title alignment. Defaults to "center" (the same on both platforms). |
headerTransparent? | boolean | The header bar sits transparent over the content (content starts below it). |
headerTitle? | (props: HeaderItemProps & { title: string; }) => ReactNode | Drawn in place of the title. |
headerLeft? | (props: HeaderItemProps) => ReactNode | Drawn on the left (in place of the back button). |
headerRight? | (props: HeaderItemProps) => ReactNode | Drawn on the right (action buttons). |
header? | (props: HeaderProps) => ReactNode | Drawn in place of the whole header bar. |
presentation? | Presentation | Presentation. Defaults to "card". |
animation? | StackAnimation | Enter animation; defaults by presentation (card → slide, modal → slideUp). |
animationDuration? | number | Animation duration (ms). |
gestureEnabled? | boolean | Swipe back (left to right on a card, top to bottom on a modal). Defaults to true. |
fullScreenGestureEnabled? | boolean | The swipe can start anywhere on the screen (not only from the left edge). |
backgroundColor? | string | Background color of the screen; defaults to the theme's background color. |
icon? | IconProp | ((props: TabIconProps) => ReactNode) | Tab icon: an icon name/data or a render function. |
badge? | Dynamic<number | string | boolean | undefined, P> | Tab badge: a number, text or true (a dot). |
tabLabel? | string | Tab label (title if omitted). |
StackDef
interfaceA nested stack definition (e.g. a tab's own pages).
| Name | Type | Description |
|---|---|---|
stack | RouteMap | Screens of the stack. |
initialRoute? | string | First screen; defaults to the first definition. |
title? | Dynamic<string, P> | Title (header bar and tab label). |
headerShown? | Dynamic<boolean, P> | Whether the header bar is shown. Defaults to true for screens and false for containers (tabs/stack). |
headerTitleAlign? | "center" | "left" | Title alignment. Defaults to "center" (the same on both platforms). |
headerTransparent? | boolean | The header bar sits transparent over the content (content starts below it). |
headerTitle? | (props: HeaderItemProps & { title: string; }) => ReactNode | Drawn in place of the title. |
headerLeft? | (props: HeaderItemProps) => ReactNode | Drawn on the left (in place of the back button). |
headerRight? | (props: HeaderItemProps) => ReactNode | Drawn on the right (action buttons). |
header? | (props: HeaderProps) => ReactNode | Drawn in place of the whole header bar. |
presentation? | Presentation | Presentation. Defaults to "card". |
animation? | StackAnimation | Enter animation; defaults by presentation (card → slide, modal → slideUp). |
animationDuration? | number | Animation duration (ms). |
gestureEnabled? | boolean | Swipe back (left to right on a card, top to bottom on a modal). Defaults to true. |
fullScreenGestureEnabled? | boolean | The swipe can start anywhere on the screen (not only from the left edge). |
backgroundColor? | string | Background color of the screen; defaults to the theme's background color. |
icon? | IconProp | ((props: TabIconProps) => ReactNode) | Tab icon: an icon name/data or a render function. |
badge? | Dynamic<number | string | boolean | undefined, P> | Tab badge: a number, text or true (a dot). |
tabLabel? | string | Tab label (title if omitted). |
RouteDef
typeAny route definition.
| Name | Type | Description |
|---|---|---|
screen | ComponentType<ScreenProps<P>> | ComponentType<Record<string, never>> | Screen component; the params type is inferred from the component's params prop.(ScreenDef) |
path? | string | Deep link path: "product/:id", an optional segment ":tab?". The query string (?ref=mail) is added to the params.(ScreenDef) |
initialParams? | Partial<P> | Used when no params are given.(ScreenDef) |
title? | Dynamic<string, P> | Title (header bar and tab label). |
headerShown? | Dynamic<boolean, P> | Whether the header bar is shown. Defaults to true for screens and false for containers (tabs/stack). |
headerTitleAlign? | "center" | "left" | Title alignment. Defaults to "center" (the same on both platforms). |
headerTransparent? | boolean | The header bar sits transparent over the content (content starts below it). |
headerTitle? | (props: HeaderItemProps & { title: string; }) => ReactNode | Drawn in place of the title. |
headerLeft? | (props: HeaderItemProps) => ReactNode | Drawn on the left (in place of the back button). |
headerRight? | (props: HeaderItemProps) => ReactNode | Drawn on the right (action buttons). |
header? | (props: HeaderProps) => ReactNode | Drawn in place of the whole header bar. |
presentation? | Presentation | Presentation. Defaults to "card". |
animation? | StackAnimation | Enter animation; defaults by presentation (card → slide, modal → slideUp). |
animationDuration? | number | Animation duration (ms). |
gestureEnabled? | boolean | Swipe back (left to right on a card, top to bottom on a modal). Defaults to true. |
fullScreenGestureEnabled? | boolean | The swipe can start anywhere on the screen (not only from the left edge). |
backgroundColor? | string | Background color of the screen; defaults to the theme's background color. |
icon? | IconProp | ((props: TabIconProps) => ReactNode) | Tab icon: an icon name/data or a render function. |
badge? | Dynamic<number | string | boolean | undefined, P> | Tab badge: a number, text or true (a dot). |
tabLabel? | string | Tab label (title if omitted). |
tabs | RouteMap | Tabs (in order). Each can be a screen or a container.(TabsDef) |
initialRoute? | string | Tab opened first; defaults to the first tab.(TabsDef | StackDef) |
tabAnimation? | TabAnimation | Tab transition animation. Defaults to "fade".(TabsDef) |
backBehavior? | TabBackBehavior | Back button behavior. Defaults to "history".(TabsDef) |
lazy? | boolean | Whether tab screens are created on first open (default true) or all up front.(TabsDef) |
hideTabBarOnKeyboard? | boolean | Hide the tab bar while the keyboard is open. Defaults to true.(TabsDef) |
tabBar? | (props: TabBarProps) => ReactNode | Drawn in place of the tab bar.(TabsDef) |
stack | RouteMap | Screens of the stack.(StackDef) |
RouteMap
typeName → route definition.
TabBarProps
interfaceInfo passed to the tab bar.
| Name | Type | Description |
|---|---|---|
tabs | { /** Route name. */ name: string; /** Label. */ label: string; /** Options. */ options: ResolvedOptions; /** Whether it is selected. */ focused: boolean; }[] | Tabs. |
onPress | (name: string) => void | Switches to the tab (returns to the start of its stack if already selected). |
ParamList
typeAll names in the route map (nested ones included) → param types.
Register
interfaceExtended to declare the app's routes; useNavigation() checks names and params against it.
Examples
AppParamList
typeParam map of the registered routes.
RouteName
typeRegistered route names.
ParamsOf
typeParams of a route.
ParamArgs
typeA required argument if the params are required, otherwise optional.
RouteState
interfaceState of a route.
| Name | Type | Description |
|---|---|---|
key | string | Unique key. |
name | string | Route name. |
params? | object | Params. |
state? | NavigatorState | Inner state of container routes. |
PreventRemoveEvent
interfaceInfo passed to the usePreventRemove callback.
| Name | Type | Description |
|---|---|---|
proceed | () => void | Applies the blocked operation anyway (e.g. when "Leave" is confirmed). |