react-native-screens vs react-native-gesture-handler vs react-native-reanimated vs react-navigation vs react-native-navigation
React Native Navigation and Animation Libraries
react-native-screensreact-native-gesture-handlerreact-native-reanimatedreact-navigationreact-native-navigationSimilar Packages:
React Native Navigation and Animation Libraries

React Native navigation and animation libraries provide tools for managing screen transitions, gestures, and animations in React Native applications. These libraries help developers create smooth, interactive, and visually appealing user interfaces by handling navigation logic, gesture recognition, and animation performance. They offer features like stack navigation, tab navigation, drawer navigation, and customizable animations, making it easier to build complex mobile apps with intuitive navigation and engaging user experiences. These libraries are essential for creating polished and professional mobile applications that feel native and responsive.

Npm Package Weekly Downloads Trend
3 Years
Github Stars Ranking
Stat Detail
Package
Downloads
Stars
Size
Issues
Publish
License
react-native-screens2,260,0703,5282.55 MB184a month agoMIT
react-native-gesture-handler2,198,1246,6073.28 MB74a month agoMIT
react-native-reanimated2,169,72110,4753.89 MB3155 hours agoMIT
react-navigation66,14024,293698 B8852 years agoMIT
react-native-navigation20,76313,1515.43 MB25516 days agoMIT
Feature Comparison: react-native-screens vs react-native-gesture-handler vs react-native-reanimated vs react-navigation vs react-native-navigation

Gesture Handling

  • react-native-screens:

    react-native-screens does not provide gesture handling features directly. Its primary focus is on optimizing screen management and navigation performance by using native screen components. Gesture handling is typically managed by the navigation library used in conjunction with react-native-screens, such as React Navigation.

  • react-native-gesture-handler:

    react-native-gesture-handler provides advanced gesture handling capabilities, allowing developers to create custom gestures, swipe actions, and complex touch interactions. It offers better performance and flexibility compared to the default gesture system in React Native, making it ideal for apps that require precise and responsive gesture recognition.

  • react-native-reanimated:

    react-native-reanimated excels in handling gestures in conjunction with animations. It allows developers to create highly performant and interactive animations that respond to gestures, such as drag-and-drop, swipe, and pinch, with fine-grained control over the animation lifecycle.

  • react-navigation:

    react-navigation provides basic gesture handling for navigation, including swipe-to-go-back and drag-to-open gestures for drawers. It is built on top of react-native-gesture-handler, which allows for more advanced gesture handling if needed. However, its primary focus is on providing a comprehensive navigation solution rather than specialized gesture handling.

  • react-native-navigation:

    react-native-navigation focuses on native navigation experiences and does not provide specialized gesture handling features. However, it supports standard gestures for navigation, such as swipe-to-go-back, which are implemented natively for smooth performance.

Navigation Performance

  • react-native-screens:

    react-native-screens improves navigation performance by using native screen components, which reduces the memory footprint and enhances the efficiency of screen transitions. This optimization is particularly beneficial for apps with deep navigation stacks or multiple screens.

  • react-native-gesture-handler:

    react-native-gesture-handler improves the performance of gesture recognition by handling gestures on the native side, reducing the overhead of JavaScript thread processing. This leads to smoother and more responsive interactions, especially for complex gestures and animations.

  • react-native-reanimated:

    react-native-reanimated enhances animation performance by running animations on the native thread, minimizing the impact on the JavaScript thread. This allows for smooth and fluid animations, even when dealing with complex interactions and multiple animated elements.

  • react-navigation:

    react-navigation provides good performance for most navigation scenarios, but it is primarily a JavaScript-based solution. Performance can be improved by integrating it with react-native-screens and react-native-gesture-handler, which help optimize screen management and gesture handling.

  • react-native-navigation:

    react-native-navigation offers high-performance navigation by leveraging native navigation components and APIs. This results in faster screen transitions, lower memory usage, and a more seamless user experience compared to purely JavaScript-based navigation solutions.

Animation Capabilities

  • react-native-screens:

    react-native-screens does not provide animation capabilities directly. Its primary role is to optimize screen management and navigation performance. Animations are handled by the navigation library used alongside react-native-screens, such as React Navigation or React Native Navigation.

  • react-native-gesture-handler:

    react-native-gesture-handler focuses on gesture recognition and does not provide built-in animation capabilities. However, it can be used in conjunction with animation libraries like react-native-reanimated to create interactive animations that respond to gestures.

  • react-native-reanimated:

    react-native-reanimated is a powerful animation library that allows developers to create complex and highly customizable animations. It runs animations on the native thread, ensuring smooth performance even for resource-intensive animations. The library supports a wide range of animation types, including spring, decay, and timing animations, as well as gesture-driven animations.

  • react-navigation:

    react-navigation offers built-in support for various navigation animations, including stack, tab, and drawer transitions. It provides a simple API for customizing animations and supports third-party animation libraries for more advanced use cases. The library is flexible and allows developers to create smooth and visually appealing navigation experiences.

  • react-native-navigation:

    react-native-navigation provides native animations for screen transitions, including push, pop, and modal animations. These animations are smooth and performant, leveraging the native platform's capabilities. However, the library does not offer extensive customization options for animations beyond the standard navigation transitions.

Ease of Integration

  • react-native-screens:

    react-native-screens is designed to work seamlessly with React Navigation and other navigation libraries. Integration is straightforward, and the library provides clear instructions on how to use it to optimize screen management and performance.

  • react-native-gesture-handler:

    react-native-gesture-handler integrates seamlessly with React Native and other libraries, such as React Navigation. It requires minimal setup and provides clear documentation, making it easy for developers to implement advanced gesture handling in their apps.

  • react-native-reanimated:

    react-native-reanimated integrates well with React Native and other animation libraries. It has a steeper learning curve due to its advanced features and API, but the documentation and community resources make it easier for developers to adopt.

  • react-navigation:

    react-navigation is easy to integrate and use, with a simple API and extensive documentation. It is designed to work well with other React Native libraries, such as react-native-gesture-handler and react-native-screens, to enhance functionality and performance.

  • react-native-navigation:

    react-native-navigation requires more setup compared to JavaScript-based navigation libraries, as it involves native code integration. However, it provides comprehensive documentation and examples to help developers implement native navigation features effectively.

Ease of Use: Code Examples

  • react-native-screens:

    Optimizing Screens with react-native-screens

    import { enableScreens } from 'react-native-screens';
    import { NavigationContainer } from '@react-navigation/native';
    import { createStackNavigator } from '@react-navigation/stack';
    
    enableScreens();
    
    const Stack = createStackNavigator();
    
    const App = () => {
      return (
        <NavigationContainer>
          <Stack.Navigator>
            <Stack.Screen name="Home" component={HomeScreen} />
            <Stack.Screen name="Profile" component={ProfileScreen} />
          </Stack.Navigator>
        </NavigationContainer>
      );
    };
    
  • react-native-gesture-handler:

    Gesture Handling with react-native-gesture-handler

    import { PanGestureHandler } from 'react-native-gesture-handler';
    import { View } from 'react-native';
    
    const MyComponent = () => {
      const onGestureEvent = (event) => {
        console.log('Gesture event:', event.nativeEvent);
      };
    
      return (
        <PanGestureHandler onGestureEvent={onGestureEvent}>
          <View style={{ width: 200, height: 200, backgroundColor: 'lightblue' }} />
        </PanGestureHandler>
      );
    };
    
  • react-native-reanimated:

    Animation with react-native-reanimated

    import Animated, { useSharedValue, useAnimatedStyle, withSpring } from 'react-native-reanimated';
    import { View, Button } from 'react-native';
    
    const MyAnimatedComponent = () => {
      const offset = useSharedValue(0);
    
      const animatedStyles = useAnimatedStyle(() => {
        return {
          transform: [{ translateX: withSpring(offset.value) }],
        };
      });
    
      return (
        <>
          <Animated.View style={[{ width: 100, height: 100, backgroundColor: 'blue' }, animatedStyles]} />
          <Button title="Move" onPress={() => (offset.value = 100)} />
        </>
      );
    };
    
  • react-navigation:

    Basic Navigation with react-navigation

    import { NavigationContainer } from '@react-navigation/native';
    import { createStackNavigator } from '@react-navigation/stack';
    
    const Stack = createStackNavigator();
    
    const App = () => {
      return (
        <NavigationContainer>
          <Stack.Navigator>
            <Stack.Screen name="Home" component={HomeScreen} />
            <Stack.Screen name="Profile" component={ProfileScreen} />
          </Stack.Navigator>
        </NavigationContainer>
      );
    };
    
  • react-native-navigation:

    Native Navigation with react-native-navigation

    import { Navigation } from 'react-native-navigation';
    
    Navigation.registerComponent('Home', () => HomeScreen);
    Navigation.registerComponent('Profile', () => ProfileScreen);
    
    Navigation.setRoot({
      root: {
        stack: {
          children: [
            {
              component: {
                name: 'Home',
              },
            },
          ],
        },
      },
    });
    
How to Choose: react-native-screens vs react-native-gesture-handler vs react-native-reanimated vs react-navigation vs react-native-navigation
  • react-native-screens:

    Choose react-native-screens if you want to optimize memory usage and performance by using native screen components for navigation. It works well with other navigation libraries like React Navigation to improve the efficiency of screen transitions and reduce resource consumption.

  • react-native-gesture-handler:

    Choose react-native-gesture-handler if you need advanced gesture handling capabilities for your React Native app. It is particularly useful for implementing custom gestures, swipe actions, and complex touch interactions with better performance than the default gesture system.

  • react-native-reanimated:

    Choose react-native-reanimated if you need powerful and flexible animation capabilities that leverage the native thread for better performance. It is suitable for creating complex animations, gestures, and interactions with fine-grained control and minimal impact on the main thread.

  • react-navigation:

    Choose react-navigation if you need a comprehensive and easy-to-use navigation solution for React Native. It provides a wide range of navigation patterns, including stack, tab, and drawer navigation, with a simple API and good customization options. It is ideal for most apps that need a flexible and feature-rich navigation system without deep native integration.

  • react-native-navigation:

    Choose react-native-navigation if you require a native navigation solution with high performance and deep integration with the platform. It is ideal for apps that need native-like navigation experiences, including stack, tab, and drawer navigation, with smooth transitions and animations.

README for react-native-screens
React Native Screens by Software Mansion

This project aims to expose native navigation container components to React Native. It is not designed to be used as a standalone library but rather as a dependency of a full-featured navigation library.

Fabric

To learn about how to use react-native-screens with Fabric architecture, head over to Fabric README. Instructions on how to run Fabric Example within this repo can be found in the FabricExample README.

Supported platforms

  • iOS
  • Android
  • tvOS
  • visionOS
  • Windows
  • Web

Installation

iOS

Installation on iOS is completely handled with auto-linking, if you have ensured pods are installed after adding this module, no other actions are necessary.

Android

On Android the View state is not persisted consistently across Activity restarts, which can lead to crashes in those cases. It is recommended to override the native Android method called on Activity restarts in your main Activity, to avoid these crashes.

For most people using an app built from the react-native template, that means editing MainActivity.java, likely located in android/app/src/main/java/<your package name>/MainActivity.java

You should add this code, which specifically discards any Activity state persisted during the Activity restart process, to avoid inconsistencies that lead to crashes. Please note that the override code should not be placed inside MainActivityDelegate, but rather directly in MainActivity.

Java
import android.os.Bundle;
import com.swmansion.rnscreens.fragment.restoration.RNScreensFragmentFactory;

public class MainActivity extends ReactActivity {

    //...code

    //react-native-screens override
    @Override
    protected void onCreate(Bundle savedInstanceState) {
        getSupportFragmentManager().setFragmentFactory(new RNScreensFragmentFactory());
        super.onCreate(savedInstanceState);
    }

    public static class MainActivityDelegate extends ReactActivityDelegate {
        //...code
    }
}
Kotlin
import android.os.Bundle;
import com.swmansion.rnscreens.fragment.restoration.RNScreensFragmentFactory;

class MainActivity: ReactActivity() {

    //...code

    //react-native-screens override
    override fun onCreate(savedInstanceState: Bundle?) {
      supportFragmentManager.fragmentFactory = RNScreensFragmentFactory()
      super.onCreate(savedInstanceState);
    }
}

For people that must handle cases like this, there is a more detailed discussion of the difficulties in a series of related comments.

Need to use a custom Kotlin version?

Since v3.6.0 react-native-screens has been rewritten with Kotlin. Kotlin version used in this library defaults to 1.4.10.

If you need to use a different Kotlin version, set kotlinVersion ext property in your project's android/build.gradle and the library will use this version accordingly:

buildscript {
    ext {
        ...
        kotlinVersion = "1.4.10"
    }
}

Disclaimer: react-native-screens requires Kotlin 1.3.50 or higher.

Windows

Installation on Windows should be completely handled with auto-linking when using React Native Windows 0.63+. For earlier versions, you must manually link the native module.

How can I take advantage of that?

Screens are already integrated with the React Native's most popular navigation library react-navigation and Expo.

Supported react-native version

Below we present tables with mapping of the library version to the last supported react-native version. These tables are for the 4.x line of the library. For compat tables of 3.x line please see readme on the 3.x branch.

Support for Fabric

Fabric is React Native's default rendering system since 0.76.

Here's a table with summary of supported react-native versions:

library versionreact-native version
4.14.0+0.79.0+
4.5.0+0.77.0+
4.0.0+0.76.0+

Support for Paper

Paper is the legacy rendering system.

Here's a table with summary of supported react-native versions with old architecture turned on:

library versionreact-native version
4.14.0+0.79.0+
4.9.0+0.76.0+
4.5.0+0.74.0+
4.0.0+0.72.0+

Usage with react-navigation

[!CAUTION] JS API of the native stack has been moved from react-native-screens/native-stack to @react-navigation/native-stack since version v6. Currently, native stack v5 (imported from react-native-screens/native-stack) is deprecated and will be removed in the upcoming minor release. react-native-screens v4 will support only @react-navigation/native-stack v7.

Screens support is built into react-navigation starting from version 2.14.0 for all the different navigator types (stack, tab, drawer, etc).

To configure react-navigation to use screens instead of plain RN Views for rendering screen views, simply add this library as a dependency to your project:

# bare React Native project
yarn add react-native-screens

# if you use Expo managed workflow
npx expo install react-native-screens

Just make sure that the version of react-navigation you are using is 2.14.0 or higher.

You are all set 🎉 – when screens are enabled in your application code react-navigation will automatically use them instead of relying on plain React Native Views.

Experimental support for react-freeze

You have to use React Native 0.68 or higher, react-navigation 5.x or 6.x and react-native-screens >= v3.9.0

Since v3.9.0, react-native-screens comes with experimental support for react-freeze. It uses the React Suspense mechanism to prevent parts of the React component tree from rendering, while keeping its state untouched.

To benefit from this feature, enable it in your entry file (e.g. App.js) with this snippet:

import { enableFreeze } from 'react-native-screens';

enableFreeze(true);

Want to know more? Check out react-freeze README

Found a bug? File an issue here or directly in react-freeze repository.

Disabling react-native-screens

If, for whatever reason, you'd like to disable native screens support and use plain React Native Views add the following code in your entry file (e.g. App.js):

import { enableScreens } from 'react-native-screens';

enableScreens(false);

You can also disable the usage of native screens per navigator with detachInactiveScreens.

Using createNativeStackNavigator with React Navigation

To take advantage of the native stack navigator primitive for React Navigation that leverages UINavigationController on iOS and Fragment on Android, please refer:

FullWindowOverlay

Native iOS component for rendering views straight under the Window. Based on RCTPerfMonitor. You should treat it as a wrapper, providing full-screen, transparent view which receives no props and should ideally render one child View, being the root of its view hierarchy. For the example usage, see https://github.com/software-mansion/react-native-screens/blob/main/apps/src/tests/Test1096.tsx

Interop with react-native-navigation

React-native-navigation library already uses native containers for rendering navigation scenes so wrapping these scenes with <ScreenContainer> or <Screen> component does not provide any benefits. Yet if you would like to build a component that uses screens primitives under the hood (for example a view pager component) it is safe to use <ScreenContainer> and <Screen> components for that as these work out of the box when rendered on react-native-navigation scenes.

Interop with other libraries

This library should work out of the box with all existing react-native libraries. If you experience problems with interoperability please report an issue.

Guide for navigation library authors

If you are building a navigation library you may want to use react-native-screens to have control over which parts of the React component tree are attached to the native view hierarchy. To do that, react-native-screens provides you with the components documented here.

Common problems

Problems with header on iOS

Solution

Use ScrollView with prop contentInsetAdjustmentBehavior=“automatic” as a main container of the screen and set headerTranslucent: true in screen options.

Other problems

ProblemSolution
SVG component becomes transparent when goBackrelated PRs
Memory leak while moving from one screen to another in the same stackexplanation
LargeHeader stays small after pop/goBack/swipe gesture on iOS 14+potential fix
onScroll and onMomentumScrollEnd of previous screen triggered in bottom tabsexplanation

Contributing

There are many ways to contribute to this project. See CONTRIBUTING guide for more information. Thank you for your interest in contributing!

License

React native screens library is licensed under The MIT License.

Credits

This project has been build and is maintained thanks to the support from Shopify, Expo.io, and Software Mansion.

shopify expo swm

React Native Screens is created by Software Mansion

Since 2012 Software Mansion is a software agency with experience in building web and mobile apps. We are Core React Native Contributors and experts in dealing with all kinds of React Native issues. We can help you build your next dream product – Hire us.