Playground

Use the Sentry Playground to verify your React Native SDK setup is working correctly.

The Sentry Playground is an interactive testing utility that helps you verify your Sentry React Native SDK is properly configured and functioning. It provides a modal interface that allows you to trigger different types of errors during development to test SDK functionality.

The Playground is available as a separate export from the @sentry/react-native package:

Copied
import { withSentryPlayground } from "@sentry/react-native/playground";

Wrap your root component with withSentryPlayground to enable the Playground modal:

App.js
Copied
import * as Sentry from "@sentry/react-native";
import { withSentryPlayground } from "@sentry/react-native/playground";

Sentry.init({
  dsn: "___PUBLIC_DSN___",
});

function App() {
  return <View>{/* Your app content */}</View>;
}

export default withSentryPlayground(Sentry.wrap(App));

You can optionally provide your projectId and organizationSlug to enable the "Open Sentry" button, which opens your Sentry issues stream directly in the browser:

App.js
Copied
export default withSentryPlayground(Sentry.wrap(App), {
  projectId: "123456",
  organizationSlug: "my-org",
});

You can find these values in your Sentry project settings or in your DSN URL.

When you launch your app with the Playground enabled, a modal appears with three test scenarios:

Tests manual error capture in a try-catch scenario. This verifies that Sentry.captureException() is working correctly.

Copied
try {
  throw new Error("This is a test caught error.");
} catch (e) {
  Sentry.captureException(e);
}

Tests automatic uncaught error handling. This verifies that the React Native Global Handler is properly catching and reporting uncaught JavaScript errors.

Copied
throw new Error("This is a test uncaught error.");

Tests native crash reporting by triggering a crash in the native layer (Java on Android, Objective-C/Swift on iOS). This verifies that native crash handling is properly configured.

Once you've verified your SDK setup is working correctly, remove the Playground wrapper before deploying to production:

App.js
Copied
import * as Sentry from "@sentry/react-native";
// Remove this import
// import { withSentryPlayground } from "@sentry/react-native/playground";

Sentry.init({
  dsn: "___PUBLIC_DSN___",
});

function App() {
  return <View>{/* Your app content */}</View>;
}

// Change this:
// export default withSentryPlayground(Sentry.wrap(App));
// To this:
export default Sentry.wrap(App);

PlatformPlayground AvailableNative Crash Test
iOS (Release)YesYes
Android (Release)YesYes
iOS (Debug)YesNo
Android (Debug)YesNo
Expo GoYesNo
WebNoNo
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").