Sentry for Expo

Learn how to set up Sentry in an Expo project and capture your first events, including Expo config plugin, Expo Router tracing, Expo Updates context, and 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/agent-plugin install

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

You need Expo SDK 50 or newer. The @sentry/react-native SDK requires Expo SDK 50+. On Expo SDK 49 or older, the deprecated sentry-expo package was used; migrate to @sentry/react-native to keep receiving updates.

Use the Sentry Wizard to patch your project automatically:

Copied
npx @sentry/wizard@latest -i reactNative
The following tasks will be performed by the Sentry Wizard
  • Install the @sentry/react-native package.
  • Add @sentry/react-native/metro to the metro.config.js Metro configuration.
  • Add @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 the 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 with the supplied DSN in your layout.tsx file.

You only need to patch the project once. Add the patched files to version control. If you prefer, use the manual install below.

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

Copied
npx expo install @sentry/react-native

Error Monitoring starts working as soon as you call Sentry.init(). Logs need enableLogs: true in the initialization snippet below, and you'll learn how to send them in Send Logs. Application Metrics need no extra configuration, and you'll learn how to send them in Send Application Metrics.

This guide also enables Tracing, Profiling, Session Replay, and User Feedback.

Want to learn more about these features?
  • Issues (always enabled): Sentry's core error monitoring product that automatically reports errors, uncaught exceptions, and crashes. If you have something that looks like an exception, Sentry can capture it.
  • Tracing: Track software performance while seeing the impact of errors across multiple systems. For example, distributed tracing allows you to follow a request from the frontend to the backend and back.
  • Profiling: Gain deeper insight than traditional tracing without custom instrumentation, letting you discover slow-to-execute or resource-intensive functions in your app.
  • Session Replay: Get to the root cause of an issue faster by viewing a video-like reproduction of what users saw in your app before, during, and after the problem.
  • Logs: Centralize and analyze your application logs to correlate them with errors and performance issues. Search, filter, and visualize log data to understand what's happening in your applications.
  • Application Metrics (always enabled): Track and analyze custom application metrics, such as response times and database query durations, to understand trends and patterns in your application's performance and behavior over time.
  • User Feedback: Collect feedback directly from users when they encounter errors, allowing them to describe what happened and provide context that helps you understand and resolve issues faster.

Import @sentry/react-native and initialize the SDK in your Expo Router root layout or app entry point.

The snippet also turns on:

Don't need a feature? Remove its integration and options from the snippet.

Copied
import * as Sentry from "@sentry/react-native";

Sentry.init({
  dsn: "___PUBLIC_DSN___",
  // Adds context data to events, such as IP address, cookies, and user.
  sendDefaultPii: true,

  integrations: [
    // Enables Session Replay
    Sentry.mobileReplayIntegration(),
    // Enables User Feedback. Open the form with Sentry.showFeedbackWidget().
    Sentry.feedbackIntegration(),
  ],

  // Enables Tracing.
  // Set to 1.0 to capture 100% of spans for tracing.
  // We recommend reducing this value in production.
  tracesSampleRate: 1.0,

  // Enables Profiling for 100% of sampled transactions.
  profilesSampleRate: 1.0,

  // Enables Logs to be sent to Sentry.
  enableLogs: true,

  // Capture replays for 10% of sessions and 100% of sessions with an error.
  replaysSessionSampleRate: 0.1,
  replaysOnErrorSampleRate: 1.0,
});

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

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

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

export default Sentry.wrap(RootLayout);

To upload bundles and source maps automatically during native 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 or 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___

Add Sentry Serializer to the Metro configuration to assign unique Debug IDs to generated bundles and source maps:

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 some device and application information for essential functionality. Add the privacy manifest to your Xcode project to meet Apple's guidelines. See the Apple Privacy Manifest guide for the records required by the Sentry SDKs.

Connect Sentry to Expo Application Services (EAS) to view crash reports and Session Replays for deployments in the EAS dashboard, with direct links to Sentry stack traces and debugging context.

  1. Log in to your Expo dashboard and open Account Settings > Overview (https://expo.dev/accounts/[your-account]/settings).
  2. Find Connections and click Connect next to Sentry.
  3. Log in to Sentry and accept the integration into your organization. Expo will redirect you 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.

To see Sentry issues and replays in the Expo dashboard, create an EAS Update channel and assign builds to it to create an EAS deployment. Then open Projects > [Your Project] > Updates > Deployments > [Deployment].

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

Use Sentry.logger to send logs at different levels. You can include attributes to search or filter by later.

The SDK can capture console.* calls when Logs are enabled. See the Console logging integration for details.

Copied
Sentry.logger.info("Order processed", { order_id: "order-123" });
Sentry.logger.warn("Slow operation detected", {
  operation: "data_fetch",
  duration_ms: 3500,
});

See Set Up Logs for all available logging methods and message formatting options.

Application Metrics are supported in React Native SDK 7.8.0 and newer. No extra option is needed after SDK initialization. Use Sentry.metrics to send counters, gauges, and distributions:

Copied
Sentry.metrics.count("checkout.failed", 1);
Sentry.metrics.gauge("active_connections", 42);
Sentry.metrics.distribution("api_latency", 187, { unit: "millisecond" });

See Set Up Metrics for all available metric types and configuration options.

Build the Release version of your application, then capture a test error:

Copied
Sentry.captureException(new Error("First error"));

Open your project on Sentry.io to view the captured error.

Need help locating captured data in your Sentry project?
  • Open the Issues page and select an error from the issues list to view the full details and context of this error. For more details, see the Issue Details documentation.
  • Open the Traces page and select a trace to reveal more information about each span, its duration, and any errors. For an interactive UI walkthrough, click here.
  • Open the Profiles page to see your slowest functions and an aggregate flame graph of your most frequent code paths. If tracing is enabled, select a transaction to see the flame graph for that part of your app. For more information, click here.
  • Open the Replays page and select an entry from the list to get a detailed view where you can replay the interaction and get more information to help you troubleshoot.
  • Open the Logs page and filter by service, environment, or search keywords to view log entries from your application. For an interactive UI walkthrough, click here.
  • Open the Application Metrics page to view and analyze your metrics. For more details, see this interactive walkthrough.
  • Open the User Feedback page and click on individual feedback to see more details all in one view. For more information, click here.

At this point, you should have integrated Sentry into your Expo application. Here's what to explore next:

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").