Set up Sentry in an Expo React Native app
Wire up Sentry's React Native SDK in an Expo project so you get readable, source-mapped crash reports and performance traces straight from your devices.
Before you start
SDKs & packages
Accounts & access
- A Sentry account with a React Native project
- A Sentry auth token for uploading source maps
Knowledge
- Basic familiarity with React Native and the Expo CLI
1 Install the SDK with the Sentry Wizard
From the root of your Expo project, run the Sentry Wizard. It logs you into Sentry, lets you pick a project, installs the @sentry/react-native package, and patches your Metro and Expo config for you. If you'd rather wire everything up by hand, the manual setup guide covers each change the wizard makes.
Run the Sentry Wizardnpx @sentry/wizard@latest -i reactNative
2 Configure the Metro bundler
Sentry needs the Metro bundler to emit a unique Debug ID for every bundle and its matching source map. Wrap your config with getSentryExpoConfig from @sentry/react-native/metro so those IDs are generated automatically. The wizard adds this for you, but confirm your metro.config.js looks like the snippet below.
metro.config.js// Learn more https://docs.expo.dev/guides/customizing-metro
const { getSentryExpoConfig } = require("@sentry/react-native/metro");
const config = getSentryExpoConfig(__dirname);
module.exports = config;
3 Add the Sentry Expo config plugin
Register the @sentry/react-native/expo config plugin in your app.json (or app.config.js). This hooks Sentry into the native build so iOS and Android source maps and debug symbols upload automatically during EAS or prebuild. Replace project and organization with your own Sentry slugs.
app.json{
"expo": {
"plugins": [
[
"@sentry/react-native/expo",
{
"url": "https://sentry.io/",
"project": "your-project-slug",
"organization": "your-org-slug"
}
]
]
}
}
4 Initialize Sentry in your root layout
Call Sentry.init() as early as possible so errors are captured from the very first render. For Expo Router apps, the root app/_layout.tsx is the right place. Paste in the DSN from your Sentry project settings, and keep tracesSampleRate at 1.0 while you're getting started so every trace is captured.
app/_layout.tsximport * as Sentry from "@sentry/react-native";
Sentry.init({
dsn: "YOUR_DSN_HERE",
// Adds more context data to events (IP address, cookies, user, etc.).
// See https://docs.sentry.io/platforms/react-native/data-management/data-collected/
sendDefaultPii: true,
// Capture 100% of traces. Lower this in production.
tracesSampleRate: 1.0,
});
5 Wrap your root component
Wrap your app's root component with Sentry.wrap(). This unlocks automatic performance instrumentation, touch-event breadcrumbs, and proper error boundary handling across the whole app. Add it to the same app/_layout.tsx file, right next to your Sentry.init() call.
app/_layout.tsximport * as Sentry from "@sentry/react-native";
import { Stack } from "expo-router";
function RootLayout() {
return <Stack />;
}
export default Sentry.wrap(RootLayout);
6 Set up source map uploads
Without source maps, your stack traces point at minified bundle code instead of your TypeScript. The config plugin uploads them automatically during EAS Builds and local release builds, but it needs an auth token. Store it in a .env.local file for local builds, and add it as a secret EAS environment variable for cloud builds. Never commit the token to version control. If you ship over-the-air updates with EAS Update, those source maps don’t upload automatically: run npx @sentry/expo-upload-sourcemaps dist right after eas update.
.env.localSENTRY_AUTH_TOKEN=sntrys_YOUR_AUTH_TOKEN
7 Verify your setup
Trigger a test error to confirm events are flowing. Add a button to a screen that throws, run your app, and tap it. Within a minute the event should appear in your Issues feed with a source-mapped stack trace pointing back to your original code.
Send a test errorimport * as Sentry from "@sentry/react-native";
import { Button } from "react-native";
<Button
title="Throw a test error"
onPress={() => {
Sentry.captureException(new Error("First error from my Expo app"));
}}
/>;
That's it.
Your Expo app reports for duty.
Every crash and slow transaction in your Expo app now lands in Sentry with a readable, source-mapped stack trace.
- Installed the @sentry/react-native SDK into an Expo project with the Sentry Wizard
- Configured the Metro bundler and Expo config plugin for Sentry
- Initialized and wrapped your Expo Router app to capture errors and traces
- Set up source map uploads so stack traces point to your original code
- Verified the integration by sending a test error to Sentry
Pro tips
- 💡 Lower
tracesSampleRate(e.g.0.2) before shipping to production so you don't burn through your span quota on a high-traffic app. - 💡 Run
eas env:create --name SENTRY_AUTH_TOKEN --value sntrys_... --environment production --visibility secretso cloud builds can upload source maps without exposing the token in your repo. - 💡 Enable
Sentry.mobileReplayIntegration()to add Session Replay and watch a recording of exactly what the user did before a crash. - 💡 Set
experimental_android: { enableAndroidGradlePlugin: true, autoUploadProguardMapping: true }in the@sentry/react-native/expoplugin options so ProGuard mappings upload and minified Android native crashes are deobfuscated too. iOS debug symbols upload by default.
Common pitfalls
- ⚠️ Forgetting to set
SENTRY_AUTH_TOKEN— builds still succeed, but source maps never upload and your stack traces stay minified. - ⚠️ Calling
Sentry.init()after the app has already rendered, which means early startup errors slip through uncaptured. - ⚠️ Leaving
tracesSampleRate: 1.0in production and unexpectedly exhausting your span quota. - ⚠️ Editing
metro.config.jsto use the default Expo config instead ofgetSentryExpoConfig, which strips the Debug IDs that source maps rely on. - ⚠️ Publishing with
eas updateand assuming source maps uploaded. EAS Update bundles need a manualnpx @sentry/expo-upload-sourcemaps diststep.
Frequently asked questions
npx expo run:ios / npx expo run:android or EAS Build to test the full integration.sentry-expo package is deprecated. Migrate to @sentry/react-native, which now supports Expo natively. Sentry publishes a step-by-step migration guide for moving off sentry-expo.SENTRY_AUTH_TOKEN is set in your build environment, that the Expo config plugin is registered in app.json, and that your metro.config.js uses getSentryExpoConfig.What's next?
Fix it, don't observe it.
Get started with the only application monitoring platform that empowers developers to fix application problems without compromising on velocity.