# Set up Sentry in an Expo React Native app

> Install and configure Sentry's React Native SDK in an Expo project to capture errors, traces, and source-mapped stack traces in minutes using the Sentry Wizard.

**URL:** https://sentry.io/cookbook/set-up-sentry-expo-react-native/

---

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.

**Time:** 15-20 minutes | **Difficulty:** Beginner

## What You'll Learn

- 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

**Topics:** Error Monitoring, Tracing

**SDKs:** React Native

## Before you start

**SDKs & packages**

- An [Expo](https://docs.expo.dev/) project on Expo SDK 50 or newer

- [Node.js](https://nodejs.org/) and a package manager (npm, yarn, or pnpm)

**Accounts & access**

- A [Sentry account](https://sentry.io/signup/) with a React Native project

- A [Sentry auth token](https://sentry.io/orgredirect/organizations/:orgslug/settings/auth-tokens/) for uploading source maps

**Knowledge**

- Basic familiarity with React Native and the Expo CLI

## Steps

### 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.

```bash
npx @sentry/wizard@latest -i reactNative
```

[Expo manual setup guide](https://docs.sentry.io/platforms/react-native/guides/expo/)

### 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.

```javascript
// Learn more https://docs.expo.dev/guides/customizing-metro
const { getSentryExpoConfig } = require("@sentry/react-native/metro");

const config = getSentryExpoConfig(__dirname);

module.exports = config;
```

[Metro configuration guide](https://docs.sentry.io/platforms/react-native/manual-setup/metro/)

### 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.

```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 transaction is captured.

```javascript
import * 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 transactions for tracing. Lower this in production.
  tracesSampleRate: 1.0,
});
```

[React Native configuration options](https://docs.sentry.io/platforms/react-native/configuration/options/)

### 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.

```javascript
import * 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`.

```bash
SENTRY_AUTH_TOKEN=sntrys_YOUR_AUTH_TOKEN
```

[Expo source maps guide](https://docs.sentry.io/platforms/react-native/guides/expo/sourcemaps/uploading/expo/)

### 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](https://sentry.io/orgredirect/organizations/:orgslug/issues/) with a source-mapped stack trace pointing back to your original code.

```javascript
import * 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"));
  }}
/>;
```

## Summary

**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.

## Pro Tips

- Lower `tracesSampleRate` (e.g. `0.2`) before shipping to production so you don't burn through your transaction quota on a high-traffic app.

- Run `eas env:create --name SENTRY_AUTH_TOKEN --value sntrys_... --environment production --visibility secret` so 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/expo` plugin 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.0` in production and unexpectedly exhausting your performance-unit quota.

- Editing `metro.config.js` to use the default Expo config instead of `getSentryExpoConfig`, which strips the Debug IDs that source maps rely on.

- Publishing with `eas update` and assuming source maps uploaded. EAS Update bundles need a manual `npx @sentry/expo-upload-sourcemaps dist` step.

## FAQ

**Do I need to eject from Expo or use the bare workflow?**

No. The @sentry/react-native SDK works with Expo's managed workflow through the config plugin. You only need a development or production build (EAS Build or a local prebuild) — Sentry's native features won't run inside Expo Go.

**Does this work in Expo Go?**

JavaScript errors are captured in Expo Go, but native crash reporting, source map uploads, and native performance instrumentation require a development build or a production build. Use `npx expo run:ios` / `npx expo run:android` or EAS Build to test the full integration.

**What if I'm migrating from sentry-expo?**

The standalone `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.

**Is Sentry free for React Native projects?**

Yes. Sentry's Developer plan is free and includes error monitoring and a monthly allotment of events, transactions, and replays. You can upgrade as your app's volume grows.

**Why are my stack traces still minified?**

That almost always means source maps didn't upload. Confirm `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`.

## Next Steps

- [product/tracing](https://sentry.io/product/tracing/)

- [product/session-replay](https://sentry.io/product/session-replay/)

- [product/user-feedback](https://sentry.io/product/user-feedback/)

---

*Source: [sentry.io/cookbook/set-up-sentry-expo-react-native/](https://sentry.io/cookbook/set-up-sentry-expo-react-native/)*
