Add Sentry to React Native Projects
React Native CLI
Follow these steps for integrating Sentry in React Native CLI projects.
-
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 -
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:
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.# 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 installThe 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.react-native link @sentry/react-nativeNOTE: For self hosting, use following command for linking:
Here, the above command assumes Sentry is hosted at https://sentry.gurzu.net/.SENTRY_WIZARD_URL=https://sentry.gurzu.net/ yarn sentry-wizard -i reactNative -p ios androidExpo CLI If you are using expo-cli you need to use another SDK see: https://docs.expo.io/guides/using-sentry/