Migrate from sentry-expo

Learn about migrating from sentry-expo to @sentry/react-native

This guide scribes how to migrate from sentry-expo to @sentry/react-native in your Expo application.

First, remove sentry-expo from your dependencies:

Copied
npm uninstall sentry-expo

Install the @sentry/react-native package:

Copied
npx expo install @sentry/react-native

Replace all imports of sentry-expo with @sentry/react-native:

Copied
- import * as Sentry from 'sentry-expo';
+ import * as Sentry from '@sentry/react-native';

Replace sentry-expo exports Browser and React with @sentry/react:

Copied
- import { Browser, React } from 'sentry-expo';
+ import * as Browser from '@sentry/react';
+ import * as React from '@sentry/react';

Replace sentry-expo export Native with @sentry/react-native:

Copied
- import { Native } from 'sentry-expo';
+ import * as Sentry from '@sentry/react-native';

The enableInExpoDevelopment option is no longer supported. If you were using it, remove it and replace it with a __DEV__ check, or leave the SDK enabled in development.

Copied
Sentry.init({
-  enableInExpoDevelopment: true,
+  enabled: __DEV__,
});

Expo-specific tags are no longer added by default. If you were using them, you can add them manually:

Copied
import Constants from "expo-constants";
import * as Device from "expo-device";
import * as Updates from "expo-updates";

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

Sentry.setExtras({
  manifest: Updates.manifest,
  deviceYearClass: Device.deviceYearClass,
  linkingUri: Constants.linkingUri,
});

Sentry.setTag("expoReleaseChannel", Updates.manifest.releaseChannel);
Sentry.setTag("appVersion", Updates.manifest.version);
Sentry.setTag("appPublishedTime", Updates.manifest.publishedTime);
Sentry.setTag("expoSdkVersion", Updates.manifest.sdkVersion);
Sentry.setTag("deviceId", Constants.sessionId);
Sentry.setTag("appOwnership", Constants.appOwnership || "N/A");
if (Constants.appOwnership === "expo" && Constants.expoVersion) {
  Sentry.setTag("expoAppVersion", Constants.expoVersion);
}
Sentry.setTag("expoChannel", Updates.channel);

The sentry-expo package automatically switched to @sentry/react for react-native-web builds. This is no longer the case with @sentry/react-native which supports react-native-web out of the box.

Note that some features might not be supported or work differently in @sentry/react-native on react-native-web compared to direct usage of @sentry/react. Verify in your application that the features you use work as expected.

To continue using @sentry/react for react-native-web builds, see @sentry/react for more details about the web React package.

Next, set up the Expo and Metro plugins for @sentry/react-native.

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