Types
The types of starting the app.
NavigationApp
The navigation made by createNavigation, for AppRegistry.registerComponent.
interface NavigationApp<Roots extends RootsMap = RootsMap, AppScreens = Screens>
NavigationConfig
What createNavigation takes: screens and root, or roots with initialRoot; every other key is optional.
type NavigationConfig<
Context = void,
Roots extends RootsMap = Record<never, never>,
Target extends RootTarget<Roots> = RootTarget<Roots>,
AppScreens extends Screens = Record<never, never>,
Groups extends ScreenGroups = Record<never, never>,
Root extends FirstRoot<Context> = FirstRoot<Context>,
Patterns extends string = string,
> = BaseConfig<Context, AppScreens, Groups, Roots, Patterns> &
(SingleRootConfig<Context, Root> | NamedRootsConfig<Context, Roots, Target>)
| Member | Type | Description |
|---|---|---|
| screens | AppScreens | The screens of the app by name. |
| groups | { [Group in keyof Groups]: ScreenGroup & { screens: Groups[Group] } } | Screens sharing options, by group name. Their names are in one namespace with |
| presentation | Presentation | What every push, modal and overlay starts from; the settings of a command go over it. |
| listeners | NavigationListeners | Handlers of the events of the navigation, for as long as the app runs. |
| appProvider | AppProvider | Wraps the whole app once. With it every screen of |
| screenProvider | ScreenProvider | Wraps every screen on its own, inside |
| errorFallback | ComponentType<ErrorFallbackProps> | What a screen that failed to render shows instead, with |
| loadingFallback | LoadingFallback | What a screen shows while it waits for a lazy component or data (Suspense); nothing without it. |
| onError | (error: unknown, source: NavigationErrorSource) => void | The errors of the app: a screen that failed to render, a start that failed, and a link whose route failed. Without it they go to the console, as React and React Native report them. |
| options | AppOptionsInput | The default options of every screen, over the colors of the theme: options, or a chain built from the theme and the app's context ( |
| theme | NavigationTheme | The look of the navigation: colors of the bars, tabs and backgrounds; |
| safeArea | { edges: SafeAreaEdge[] } | The edges on which every screen keeps its content out of its safe area. Without it: the top and the sides, but those where the content goes under a bar ( |
| window | WindowOptions | The app's window, behind the screens: seen around a modal as it comes in. |
| direction | NavigationDirection | The direction of the app: |
| context | Context | The first value of the app's context, for every screen ( |
| willMount | () => void | PromiseLike<void> | Runs once per JavaScript runtime before the first root, while the splash screen shows. What the first root needs goes into the context with |
| didMount | (context: Context) => void | Runs once per JavaScript runtime, once the first root is shown, with the context. |
| splash | SplashConfig | The app's own splash in React Native: a component that shows after the native splash on a cold start of the app, while |
| linking | LinkingConfig<Context, Roots, Patterns, AllScreens<AppScreens, Groups>> | The links that open the app's screens: custom schemes, universal links (iOS) and App Links (Android), by path. A link runs after |
| rootRequired | Root | The first root, from the context as |
| roots | never | |
| initialRoot | never |
Presentation
What every push, modal and overlay of the app starts from; the settings of a command go over it.
interface Presentation
| Member | Type | Description |
|---|---|---|
| push | PushConfig | |
| modal | Omit<ModalConfig, 'onDismiss'> | |
| overlay | OverlayConfig |
WindowOptions
The app's window, behind every screen: seen around a modal while it comes in.
interface WindowOptions
| Member | Type | Description |
|---|---|---|
| backgroundColor | Color | The color of the window; without it, the system background. |
LinkingConfig
The links that open the app's screens: custom schemes, universal links (iOS) and App Links (Android).
interface LinkingConfig<Context = unknown, Roots extends RootsMap = RootsMap, Patterns extends string = string, AppScreens = Record<string, unknown>>
| Member | Type | Description |
|---|---|---|
| prefixes | string[] | The starts of the URLs the app takes: |
| routesRequired | { [Pattern in Patterns]: LinkRoute<Pattern, Context, Roots, AppScreens> } | The routes by path pattern: static parts, |
| when | (context: Context) => boolean | Whether a link may run now, from the app's context: |
| pending | 'auto' | 'manual' | What a waiting link does once |
| unmatched | (url: string) => void | A URL no route takes, or with none of |
LinkRoute
A route: a screen name, pushed with the params and the query as its props; a function, its open; or { start, open, when }.
type LinkRoute<Pattern extends string, Context, Roots extends RootsMap, AppScreens> =
| NoInfer<LinkScreen<Pattern, AppScreens>>
| LinkHandler<Pattern>
| LinkRouteConfig<Pattern, Context, Roots>
| Member | Type | Description |
|---|---|---|
| start | ( params: LinkParams<Pattern>, link: LinkInfo ) => RootTarget<Roots> | Exclude<RootLayout, string> | The first root when the link launches the app, in place of |
| open | LinkHandler<Pattern> | What the link does in a running app, and when it launches the app and the route has no |
| when | (context: Context) => boolean | Whether the link may run now, in place of |
LinkRouteConfig
A route with what it does when the link launches the app, when the app runs, and when it may run.
interface LinkRouteConfig<Pattern extends string, Context, Roots extends RootsMap>
| Member | Type | Description |
|---|---|---|
| start | ( params: LinkParams<Pattern>, link: LinkInfo ) => RootTarget<Roots> | Exclude<RootLayout, string> | The first root when the link launches the app, in place of |
| open | LinkHandler<Pattern> | What the link does in a running app, and when it launches the app and the route has no |
| when | (context: Context) => boolean | Whether the link may run now, in place of |
LinkHandler
What a route does in a running app: any commands.
type LinkHandler<Pattern extends string> = (
params: LinkParams<Pattern>,
link: LinkInfo
) => void
LinkInfo
A link as a route gets it.
interface LinkInfo
| Member | Type | Description |
|---|---|---|
| urlRequired | string | The whole URL. |
| pathRequired | string | The path the route matched, without the prefix and the query: |
| queryRequired | Record<string, string> | The query string by key; a key given twice keeps its last value. |
| initialRequired | boolean | Whether this link launched the app, or on Android a new activity of it. |
LinkParams
The params of a path pattern, each a string: 'user/:userId/:tab?' gives { userId: string; tab?: string }.
type LinkParams<Pattern extends string> = Simplify<
{ [Name in RequiredParam<Segment<Pattern>>]: string } & {
[Name in OptionalParam<Segment<Pattern>>]?: string;
}
>
PendingLink
A link that waits for when of linking.
interface PendingLink
| Member | Type | Description |
|---|---|---|
| urlRequired | string | The whole URL. |
| pathRequired | string | The path, without the prefix and the query. |
| routeRequired | string | The pattern of its route in |
| paramsRequired | Record<string, string> | The params of the path. |
| queryRequired | Record<string, string> | The query string by key. |
SplashConfig
The app's own splash in React Native: an animation, a progress. It shows after the native splash on a cold start of the app, once per process: not after a reload of the JavaScript, and not when Android makes a new activity while the JavaScript runs on.
interface SplashConfig
| Member | Type | Description |
|---|---|---|
| componentRequired | ComponentType | What the splash shows: a component without props, over the whole window. It renders before |
| minDuration | number | The least time the splash stays on screen, in ms, from when it shows: the length of its animation. |
| hide | 'auto' | 'manual' | When the splash leaves: |
| transition | RootTransition | How the first root replaces the splash: what |
Splash
What useSplash returns.
interface Splash
| Member | Type | Description |
|---|---|---|
| hide | hide(): void | Lets the splash leave, with |
| logoRequired | SplashLogo | undefined | The logo of the native splash, centered in the window at this size, as |
SplashLogo
The size of the native splash's logo: points on iOS, dp on Android.
interface SplashLogo
| Member | Type | Description |
|---|---|---|
| widthRequired | number | |
| heightRequired | number |