Skip to main content

Crash Simulation

Use simulateNativeCrash when you need to verify that your React Native crash handler, monitoring service, and release-build recovery flow all behave the way you expect.

When to simulate a crash

  • Before shipping crash reporting to production
  • After changing Sentry or Crashlytics integrations
  • When validating Android restart behavior
  • When confirming iOS limitations for native crash handling

Basic example

import {
CrashType,
simulateNativeCrash,
} from 'react-native-global-exception-handler';

simulateNativeCrash(CrashType.nsexception);

Guard the test behind development-only code

import {
CrashType,
simulateNativeCrash,
} from 'react-native-global-exception-handler';

if (__DEV__) {
global.triggerNativeCrash = () => {
simulateNativeCrash(CrashType.nsexception);
};
}
  1. Install and configure the package using Getting Started.
  2. Connect your monitoring provider:
  3. Run a JS exception test first.
  4. Run a native crash simulation in a release build.
  5. Confirm the report appears in your monitoring platform and that the app terminates or recovers as expected.

Important limitations

  • Do not leave crash simulation triggers enabled in production builds.
  • Native crash behavior differs between iOS and Android. See Native Crash Handling for platform limits.
  • Some crash types are destructive by design; use a disposable test environment when possible.

Troubleshooting

If simulation appears to do nothing:

  • Confirm you are running on iOS or Android, not web.
  • Confirm the crash type is valid for the current platform.
  • Check Troubleshooting for debug-build limitations and common setup mistakes.

Next steps