Skip to content

Add Sentry to React Native Projects


React Native CLI

Follow these steps for integrating Sentry in React Native CLI projects.

  1. To install React Native SDK of Sentry, add the dependency to your project by either using npm or yarn .

    npm install @sentry/react-native --save
    # OR
    yarn add @sentry/react-native
    
  2. Perform Linking Since Sentry SDK also supports native crashes, we need to link the SDK to your native projects.
    Above react-native >= 0.60 you need to do:

    # For self hosted, jump to NOTE section below
    npx sentry-wizard -i reactNative -p ios android
    # OR
    yarn sentry-wizard -i reactNative -p ios android
    
    # Later for iOS
    cd ios
    pod install
    
    Since Sentry SDK supports auto-linking and iOS relies on CocoaPods, you need to install the dependencies. If you are running a project with react-native < 0.60 you still need to call react-native link.

    react-native link @sentry/react-native
    
    The link step or the sentry-wizard call will patch your project accordingly. The Sentry Wizard will guide you through the process of setting everything up correctly. This has to be done only once, and the files created can go into your version control system.

    NOTE:
    For self hosting, use following command for linking:

    SENTRY_WIZARD_URL=https://sentry.gurzu.net/ yarn sentry-wizard -i reactNative -p ios android
    
    Here, the above command assumes Sentry is hosted at https://sentry.gurzu.net/.

    Expo CLI
    If you are using expo-cli you need to use another SDK see:
    https://docs.expo.io/guides/using-sentry/