# Expo | Sentry for React Native

Sentry's React Native SDK works out of the box with Expo applications. To see readable stack traces in the product, you must upload source maps to Sentry. This guide explains how to upload source maps for Expo applications.

## [Prerequisities](https://docs.sentry.io/.md#prerequisities)

* [Sign up for an account](https://sentry.io/signup.md)
* [Migrate from `sentry-expo` to `@sentry/react-native`](https://docs.sentry.io/platforms/react-native/migration/sentry-expo.md)
* [Set up Sentry React Native SDK](https://docs.sentry.io/platforms/react-native/manual-setup/expo.md) version 5.16.0-alpha.4 or newer

## [Common Setup](https://docs.sentry.io/.md#common-setup)

To upload source maps, the Sentry Expo Plugin and the Sentry Metro Plugin need to be added to the Expo application.

### [Add the Sentry Expo Plugin](https://docs.sentry.io/.md#add-the-sentry-expo-plugin)

To ensure bundles and source maps are automatically uploaded during the local and EAS native applications builds, add the `@sentry/react-native/expo` config plugin to the Expo application configuration:

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

Add auth token to your environment:

```bash
# DO NOT COMMIT YOUR AUTH TOKEN
export SENTRY_AUTH_TOKEN=sntrys_YOUR_TOKEN_HERE
```

### [Add the Sentry Metro Plugin](https://docs.sentry.io/.md#add-the-sentry-metro-plugin)

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

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

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

module.exports = config;
```

## [Automatic Upload for Release](https://docs.sentry.io/.md#automatic-upload-for-release)

When the Sentry Expo Plugin `@sentry/react-native/expo` and the Sentry Metro Plugin are added to your application configuration, source maps for the native builds are uploaded automatically during EAS Builds and when building the native application release locally using `npx expo prebuild`. Because symbolication is already handled by the Metro dev server, automatic uploading of source maps for debug builds is disabled.

## [Manual Upload for EAS Updates](https://docs.sentry.io/.md#manual-upload-for-eas-updates)

To upload source maps for EAS Updates and `npx expo export`, set up the Sentry Expo Plugin, the Sentry Metro plugin and execute the `sentry-expo-upload-sourcemaps` command.

### [Create Update](https://docs.sentry.io/.md#create-update)

To create an update for the application use the following command:

```bash
# npx expo export --dump-sourcemap
eas update
```

### [Upload Source Maps](https://docs.sentry.io/.md#upload-source-maps)

To upload source maps for all platforms use the following command:

```bash
SENTRY_AUTH_TOKEN=sntrys_YOUR_TOKEN_HERE \
npx sentry-expo-upload-sourcemaps dist
```

To upload source maps without expo plugin (bare workflow):

```bash
SENTRY_AUTH_TOKEN=sntrys_YOUR_TOKEN_HERE \
SENTRY_PROJECT=example-project \
SENTRY_ORG=example-org \
SENTRY_URL=https://sentry.io/ \
npx sentry-expo-upload-sourcemaps dist
```

#### [Notes](https://docs.sentry.io/.md#notes)

* `dist` is the default output directory of `eas update`.
* Sentry Org, Sentry Project, and Sentry Url will be loaded from the expo plugin config (app.json / app.config.js) if the environment variable isn't set.
* Uploaded source maps have no associated releases. This is expected as updates can apply to multiple releases.

## [Notes](https://docs.sentry.io/.md#notes-1)

For a guide on how to manually upload source maps for Expo application releases, see the [Expo (Advanced)](https://docs.sentry.io/platforms/react-native/sourcemaps/uploading/expo-advanced.md) source maps docs.
