Expo

Learn how to set up an Expo project with Sentry's React Native SDK, including the Sentry Expo config plugin, Expo Router tracing, Expo Updates context, and the EAS dashboard integration.

Agent-Assisted Setup
Use curl to download, read and follow https://skills.sentry.dev/instrument to set up the Sentry Expo SDK.
Your agent will set up Sentry in your Expo app automatically. Works with Cursor, Claude Code, Codex, and more.View docs ↗
Install the full plugin

Install the Sentry plugin to give your assistant every skill. See the installation docs for more details.

Copied
npx @sentry/ai install

Use this guide to get fully set up with Sentry's React Native SDK in an Expo project. The same @sentry/react-native SDK powers both bare React Native and Expo apps. This guide covers the Expo-specific setup (config plugin, Metro, EAS) and integrations.

Use the Sentry Wizard to patch your project automatically, as shown below. Alternatively, you can follow the Manual Install if you prefer. You only need to patch the project once. Then, you can add the patched files to your version control system.

Copied
npx @sentry/wizard@latest -i reactNative
The following tasks will be performed by the Sentry Wizard
  • Install the @sentry/react-native package.
  • Add the @sentry/react-native/metro to the metro.config.js Metro configuration.
  • Add the @sentry/react-native/expo to the app.json Expo configuration.
  • Enable the Sentry React Native Gradle build step for Android to auto-upload generated source maps and debug symbols.
  • Wrap the Bundle React Native code and images Xcode project build phase script to upload generated source maps and collect bundled node modules.
  • Add Upload Debug Symbols to Sentry Xcode project build phase.
  • Run pod install.
  • Store build credentials in ios/sentry.properties, android/sentry.properties and .env.local.
  • Configure Sentry for the supplied DSN in your layout.tsx file.

If you don't use the Wizard, install the @sentry/react-native package:

Copied
npx expo install @sentry/react-native

Import the @sentry/react-native package and call init with your DSN:

Copied
import { Stack } from "expo-router";
import * as Sentry from "@sentry/react-native";

Sentry.init({
  dsn: "___PUBLIC_DSN___",
  // Adds more context data to events (IP address, cookies, user, etc.)
  // For more information, visit: https://docs.sentry.io/platforms/react-native/data-management/data-collected/
  sendDefaultPii: true,
  // ___PRODUCT_OPTION_START___ performance
  // Set tracesSampleRate to 1.0 to capture 100% of transactions for tracing.
  // We recommend adjusting this value in production.
  // Learn more at
  // https://docs.sentry.io/platforms/react-native/configuration/options/#traces-sample-rate
  tracesSampleRate: 1.0,
  // ___PRODUCT_OPTION_END___ performance
  // ___PRODUCT_OPTION_START___ logs
  // Enable logs to be sent to Sentry
  // Learn more at https://docs.sentry.io/platforms/react-native/logs/
  enableLogs: true,
  // ___PRODUCT_OPTION_END___ logs
  // ___PRODUCT_OPTION_START___ profiling
  // profilesSampleRate is relative to tracesSampleRate.
  // Here, we'll capture profiles for 100% of transactions.
  profilesSampleRate: 1.0,
  // ___PRODUCT_OPTION_END___ profiling
  // ___PRODUCT_OPTION_START___ session-replay
  // Record session replays for 100% of errors and 10% of sessions
  replaysOnErrorSampleRate: 1.0,
  replaysSessionSampleRate: 0.1,
  integrations: [Sentry.mobileReplayIntegration()],
  // ___PRODUCT_OPTION_END___ session-replay
});

function RootLayout() {
  return <Stack />;
}

export default Sentry.wrap(RootLayout);

Wrap the root component of your application with Sentry.wrap:

Copied
export default Sentry.wrap(RootLayout);

To ensure bundles and source maps are automatically uploaded during the native application builds, add the Sentry plugin to your Expo app configuration. Add it to the plugins array in app.json, or wrap your config with withSentry in app.config.js/app.config.ts:

Copied
{
  "expo": {
    "plugins": [
      [
        "@sentry/react-native/expo",
        {
          "url": "https://sentry.io/",
          "note": "Use SENTRY_AUTH_TOKEN env to authenticate with Sentry.",
          "project": "___PROJECT_SLUG___",
          "organization": "___ORG_SLUG___"
        }
      ]
    ]
  }
}

Add your auth token to a .env.local file in the root of your project:

.env.local
Copied
# DO NOT COMMIT YOUR AUTH TOKEN
SENTRY_AUTH_TOKEN=___ORG_AUTH_TOKEN___

To ensure unique Debug IDs get assigned to the generated bundles and source maps, add Sentry Serializer to the Metro configuration:

Copied
// const { getDefaultConfig } = require("expo/metro-config");
const { getSentryExpoConfig } = require("@sentry/react-native/metro");

// const config = getDefaultConfig(__dirname);
const config = getSentryExpoConfig(__dirname);

module.exports = config;

The SDK needs access to certain information about the device and the application for its essential functionality. Some of the APIs required for this are considered privacy-relevant. Add the privacy manifest to your Xcode project to ensure your app is compliant with Apple's guidelines. Read the Apple Privacy Manifest guide for more info on how to add records required for the Sentry SDKs.

To verify that everything is working as expected, build the Release version of your application and send a test event to Sentry by adding:

Copied
<Button
  title="Try!"
  onPress={() => {
    Sentry.captureException(new Error("First error"));
  }}
/>;

  • Don't commit your auth token. Store it in .env.local as SENTRY_AUTH_TOKEN for local builds, and as an EAS secret for EAS builds.
  • Source maps for the Release version of your application are uploaded automatically during the native application build.
  • During development, the source code is resolved using the Metro Server and source maps aren't used. This currently doesn't work on web.

Once the SDK is set up, you can also connect Sentry to Expo Application Services (EAS) so crash reports and Session Replays for your deployments show up directly in your EAS dashboard, with direct links to Sentry stack traces and full debugging context.

  1. Log in to your Expo dashboard and open Account Settings > Overview (https://expo.dev/accounts/[your-account]/settings).
  2. Locate the Connections section and click Connect next to Sentry.
  3. Log in to Sentry and accept the integration into your organization. You'll be redirected back to Account Settings > Overview.

After connecting your accounts, link your Expo project to your Sentry project:

  1. Open Projects > [Your Project] > Configuration > Project settings in the Expo dashboard.
  2. Click Link and select your Sentry project from the dropdown.

To see your Sentry issues and replays in the Expo dashboard, first make sure you've created an EAS Update channel and assigned builds to it to create an EAS deployment. Then:

  1. Open Projects > [Your Project] > Updates > Deployments > [Deployment] to view Sentry data from a release.
Was this helpful?
Help improve this content
Our documentation is open source and available on GitHub. Your contributions are welcome, whether fixing a typo (drat!) or suggesting an update ("yeah, this would be better").