Sentry for React Native: setup and source maps
Run npx @sentry/wizard@latest -i reactNative in your project: it installs the @sentry/react-native npm package, adds Sentry.init, and patches Metro, Xcode and Gradle so release builds upload source maps and debug symbols. On Expo (SDK 50 or newer) the same package works through the @sentry/react-native/expo config plugin. If your release stack traces show index.android.bundle or main.jsbundle line 1 instead of your files, the source maps for that exact release and dist never reached Sentry; fix that before anything else.
Steps
- Run the wizardRun npx @sentry/wizard@latest -i reactNative and commit the Metro, Xcode, Gradle and app.json changes it makes.
- Set the token in CIProvide SENTRY_AUTH_TOKEN to every release build, including EAS builds as a sensitive environment variable.
- Build a release and testFrom a release build, throw a JavaScript error and call Sentry.nativeCrash(), then check both traces show your files.
- Upload OTA mapsAfter every EAS Update or CodePush release, upload that bundle's source maps too.
Install @sentry/react-native: wizard or manual
The wizard is the path Sentry recommends and the one that gets source maps right on the first build:
npx @sentry/wizard@latest -i reactNativeIt installs @sentry/react-native, writes Sentry.init, and patches metro.config.js, app.json, Gradle and the Xcode build phases. Initialise as early as possible and wrap the root component:
import * as Sentry from '@sentry/react-native';
Sentry.init({
dsn: 'https://<key>@o<orgId>.ingest.sentry.io/<projectId>',
sendDefaultPii: true,
tracesSampleRate: 1.0, // lower this in production
});
export default Sentry.wrap(App);Sentry.wrap adds touch event tracking and automatic tracing; error monitoring starts as soon as Sentry.init() runs. The current docs' snippet also shows Sentry.mobileReplayIntegration() with replaysSessionSampleRate and replaysOnErrorSampleRate for Session Replay, Sentry.feedbackIntegration() for user feedback, and enableLogs: true; leave out what you don't use.
For a manual install in a bare app: npm install @sentry/react-native --save, then make three build changes yourself:
| Where | Change |
|---|---|
metro.config.js | Export withSentryConfig(config) from @sentry/react-native/metro (adds Debug IDs to bundles and maps) |
| Xcode, Bundle React Native code and images | Run node_modules/@sentry/react-native/scripts/sentry-xcode.sh around the React Native script |
| Xcode, new Run Script phase | /bin/sh ../node_modules/@sentry/react-native/scripts/sentry-xcode-debug-files.sh (uploads dSYMs) |
android/app/build.gradle | apply from: "../../node_modules/@sentry/react-native/sentry.gradle" before the android block |
ios/ and android/ | sentry.properties with defaults.url, defaults.org=acme, defaults.project=web |
Keep the auth token out of sentry.properties in git; set SENTRY_AUTH_TOKEN in the build environment instead. As of November 2026 the npm package is at version 8.37.0.
Expo vs bare React Native
Expo projects use the same @sentry/react-native package; the old sentry-expo package was for Expo SDK 49 and earlier and is deprecated. On SDK 50 or newer:
npx expo install @sentry/react-nativeAdd "@sentry/react-native/expo" to plugins in app.json (with url, project and organization), or wrap the config with withSentry in app.config.js. Replace the default Metro config with:
const { getSentryExpoConfig } = require('@sentry/react-native/metro');
const config = getSentryExpoConfig(__dirname);
module.exports = config;For EAS Build, store the token as a sensitive EAS environment variable: eas env:set --name SENTRY_AUTH_TOKEN --value $SENTRY_AUTH_TOKEN with --environment for each profile. Release source maps then upload during the native build. Over-the-air updates are a separate bundle with their own maps, so upload them after each update:
eas update --branch production && npx sentry-expo-upload-sourcemaps distForgetting that second step is why crashes from an EAS Update are minified while crashes from the store build are fine.
Source maps for release builds (and why traces are unreadable)
Debug builds never upload source maps: the Metro dev server symbolicates them. Release builds get maps uploaded automatically from Xcode and Gradle (SDK 5.11.0 or later) if you don't use custom release or dist values. When traces in Sentry are minified, the causes in order of frequency:
- No auth token in CI. The upload step fails or is skipped; with
SENTRY_ALLOW_FAILURE=truethe build still succeeds, silently. - Custom
releaseordist. If you set them inSentry.init, the automatic upload no longer matches; set the same values for the upload (for exampleexport SENTRY_DIST=$CI_BUILD_NUMBERon Xcode Cloud) or upload manually. - One dist for two platforms. iOS and Android ship different bundles; include the platform in
distwhen you set it yourself. - Bundle name mismatch. A frame at
app:///index.bundleneeds files namedindex.bundleandindex.bundle.map. Don't remove theRewriteFramesintegration that produces these paths. - OTA updates (EAS Update, CodePush) shipped without their own upload.
The event shows There was 1 problem processing this event: Source code was not found when Sentry couldn't match a map. Maps uploaded after the crash don't fix events already received; the next event will be readable. More on the general mechanism in Sentry source maps.
Hermes
Hermes is React Native's default engine, and the Sentry SDK works with it out of the box. The difference is the extra compile step: Metro produces a bundle and map, hermesc compiles the bundle to bytecode with its own map, and the two maps must be composed into one before upload. The wizard's build scripts do this. If you do it by hand, the order is: build with withSentryConfig in Metro, run hermesc -O -emit-binary -output-source-map, rename the Metro map to *.packager.map, run node_modules/react-native/scripts/compose-source-maps.js, then node_modules/@sentry/react-native/scripts/copy-debugid.js so the composed map keeps the Debug ID, and upload:
node_modules/@sentry/cli/bin/sentry-cli sourcemaps upload --debug-id-reference \
--strip-prefix /path/to/project \
index.android.bundle index.android.bundle.mapThe uploaded bundle is 0 bytes; that is expected. If Hermes traces still look wrong, open the event's Contexts → React Native → Hermes Debug Info. If it says true, the app shipped without Hermes source maps being applied, and Sentry's docs say to follow the JavaScript Core upload guide instead.
Native crashes and common errors
A crash in Objective-C, Swift, Java or C++ code (a native module, a third-party SDK) arrives as a native event, readable only with dSYMs on iOS, which the sentry-xcode-debug-files.sh phase uploads. Test both layers from a release build: throw new Error('My first Sentry error!') for JavaScript and Sentry.nativeCrash() for native.
| Message | Fix |
|---|---|
WARN: Unhandled promise rejections might not be caught by Sentry. | The SDK couldn't install its rejection handler; follow the SDK's promise integration setup (see unhandled promise rejections) |
IllegalStateException: Sentry SDK has detected a mix of versions | Set autoInstallation { enabled = false } in the sentry block of android/app/build.gradle |
Circular dependency between the following tasks: | Upgrade the Android Gradle Plugin to 7.4 or newer |
No bundle URL present after adding Sentry | Two tools wrap the same Xcode build phase; keep one wrapper or chain them |
Jest: SyntaxError: Unexpected token 'export' | Add @sentry/.* to transformIgnorePatterns |
| Build fails only on machines using nvm or Volta | Set export NODE_BINARY=… in the build phase so Xcode finds Node |
The mistake people make next: fixing source maps, then judging the fix by an old issue. Old events stay minified; trigger a new error from the new build, or check the next release's events.
Questions
Why are my debug builds readable but release builds not?
Debug builds are symbolicated by the Metro dev server and never upload source maps. Only release builds upload them, so a missing token or mismatched release only shows up there.
Why does my Sentry React Native trace say index.android.bundle:1?
That is a minified frame: no source map matched the event's bundle, release and dist. Check that the release build uploaded maps with the auth token and the same release and dist values.
Do I still need sentry-expo?
No. sentry-expo was for Expo SDK 49 and earlier and is deprecated; Expo SDK 50 and newer use @sentry/react-native with its Expo config plugin.
Sources
- React Nativedocs.sentry.io
- Expodocs.sentry.io
- Hermesdocs.sentry.io
- Troubleshootingdocs.sentry.io