Native navigation primitives for React Native apps with native screen management and transitions.
npx @tessl/cli install tessl/npm-react-native-screens@4.16.0React Native Screens provides native navigation primitives for React Native applications, offering superior performance through native screen management. It enables true native screens instead of plain React Native Views, leading to better memory management, improved transition performance, and seamless integration with platform navigation patterns.
npm install react-native-screensESM:
import {
enableScreens,
Screen,
InnerScreen,
ScreenStack,
ScreenStackItem,
ScreenContainer,
SearchBar,
ScreenStackHeaderConfig
} from "react-native-screens";CommonJS:
const {
enableScreens,
Screen,
InnerScreen,
ScreenStack,
ScreenStackItem,
ScreenContainer,
SearchBar,
ScreenStackHeaderConfig
} = require("react-native-screens");import React from 'react';
import { View, Text } from 'react-native';
import {
enableScreens,
Screen,
ScreenStack,
ScreenStackHeaderConfig
} from 'react-native-screens';
// Enable native screens (typically done in index.js)
enableScreens();
function App() {
return (
<ScreenStack>
<Screen active={1}>
<ScreenStackHeaderConfig title="Home" />
<View>
<Text>Home Screen Content</Text>
</View>
</Screen>
</ScreenStack>
);
}React Native Screens is built around several key architectural concepts:
Screen component represents a true native screen rather than a React Native ViewScreenStack provides native navigation stack functionality with platform-appropriate transitionsEssential functions for enabling and configuring the native screens functionality.
function enableScreens(shouldEnableScreens?: boolean): void;
function enableFreeze(shouldEnableReactFreeze?: boolean): void;
function screensEnabled(): boolean;
function freezeEnabled(): boolean;Main components for creating and managing native screen hierarchies.
function Screen(props: ScreenProps): JSX.Element;
function InnerScreen(props: ScreenProps): JSX.Element;
function ScreenContainer(props: ScreenContainerProps): JSX.Element;
function ScreenStack(props: ScreenStackProps): JSX.Element;
function ScreenStackItem(props: ScreenStackItemProps): JSX.Element;
function FullWindowOverlay(props: ViewProps): JSX.Element;
function ScreenFooter(props: ViewProps): JSX.Element;
function ScreenContentWrapper(props: ViewProps): JSX.Element;
function SearchBar(props: SearchBarProps): JSX.Element;Components for configuring native navigation headers with platform-specific styling.
function ScreenStackHeaderConfig(props: ScreenStackHeaderConfigProps): JSX.Element;
function ScreenStackHeaderLeftView(props: ViewProps): JSX.Element;
function ScreenStackHeaderCenterView(props: ViewProps): JSX.Element;
function ScreenStackHeaderRightView(props: ViewProps): JSX.Element;
function ScreenStackHeaderBackButtonImage(props: ViewProps): JSX.Element;Utility functions, hooks, and configuration objects for navigation behavior.
const isSearchBarAvailableForCurrentPlatform: boolean;
function executeNativeBackPress(): boolean;
function useTransitionProgress(): TransitionProgressContext;Beta and experimental components including bottom tabs, split views, and advanced screen hosting.
function BottomTabs(props: BottomTabsProps): JSX.Element;
function BottomTabsScreen(props: BottomTabsScreenProps): JSX.Element;
function SplitViewHost(props: SplitViewHostProps): JSX.Element;
function SplitViewScreen(props: SplitViewScreenProps): JSX.Element;Comprehensive TypeScript definitions for all components, props, and configuration options.
interface ScreenProps {
active?: 0 | 1 | Animated.AnimatedInterpolation<number>;
stackPresentation?: StackPresentationTypes;
stackAnimation?: StackAnimationTypes;
gestureEnabled?: boolean;
statusBarStyle?: 'inverted' | 'auto' | 'light' | 'dark';
// ... extensive additional properties
}
type StackPresentationTypes =
| 'push'
| 'modal'
| 'transparentModal'
| 'containedModal'
| 'containedTransparentModal'
| 'fullScreenModal'
| 'formSheet'
| 'pageSheet';
type StackAnimationTypes =
| 'default'
| 'fade'
| 'fade_from_bottom'
| 'flip'
| 'none'
| 'simple_push'
| 'slide_from_bottom'
| 'slide_from_right'
| 'slide_from_left'
| 'ios_from_right'
| 'ios_from_left';React Native Screens is designed to work seamlessly with popular navigation libraries:
For applications upgrading from React Navigation v5 or earlier, enable native screens by calling enableScreens() early in your app initialization. For newer React Navigation versions, native screens are enabled by default when this package is installed.
interface CompatibilityFlags {
isNewBackTitleImplementation: boolean;
usesHeaderFlexboxImplementation: boolean;
}
interface FeatureFlags {
experiment: {
controlledBottomTabs: boolean;
};
stable: {};
}
const compatibilityFlags: CompatibilityFlags;
const featureFlags: FeatureFlags;These flags enable downstream navigation libraries to detect feature availability and maintain backward compatibility across different versions of react-native-screens.