A modern React Native library for JavaScript and native exception handling, graceful fallback flows, and crash-reporting integrations.
π¬ See live demos of iOS and Android crash handling in action!
- π₯ Modern Architecture Support: Works with both legacy and new architecture React Native projects
- π― Dual Exception Handling: Capture uncaught JavaScript exceptions and native crashes in one place
- π Chained Native Handlers: Preserve existing crash flows when another SDK already owns the handler
- π Crash Simulation: Use
simulateNativeCrashto validate release-mode behavior safely - π‘ Reporting Integrations: Forward events to Sentry, Crashlytics, or your own backend
- β‘ TypeScript Support: Full type definitions for handlers and options
In React Native apps, uncaught failures behave differently depending on the environment:
- In DEV mode: you usually get a helpful Red Screen with a stack trace
- In production (bundled) mode: the app can quit or crash with far less context
That makes it harder to answer basic questions:
- What failed?
- Was it a JavaScript exception or a native crash?
- Should the app show fallback UI, restart, or just log the failure?
- Did the crash report actually reach Sentry, Crashlytics, or your own backend?
This package helps by giving you one place to:
- Register JavaScript and native exception handlers
- Wire crash reporting to Sentry, Crashlytics, or your own backend
- Define fallback or restart behavior where the platform allows it
- Validate native crash behavior before you ship
- Getting Started - First install and handler setup
- Installation - iOS, Android, and linking checks
- Basic Usage - Register JavaScript and native handlers
- Native Crash Handling - Platform limits and release testing
- API Reference - Public API and option behavior
- Testing & Simulation -
simulateNativeCrashand validation - Sentry Integration - Forward reports to Sentry
- Crashlytics Integration - Forward reports to Crashlytics
- Troubleshooting - Common setup and release issues
- Migration Guide - Move from
react-native-exception-handler
- Machine-readable guide - canonical
llms.txtentrypoint - AI Agents docs page - task map, caveats, and API-at-a-glance notes
npm install react-native-global-exception-handler
# or
yarn add react-native-global-exception-handlerRequires React Native 0.68+ (TurboModules & auto-linking)
Designed to work with both:
- Legacy Architecture
- New Architecture (TurboModules + Fabric)
No extra setup is usually required beyond installing the package, running pods on iOS, and rebuilding the app.
import { setJSExceptionHandler } from 'react-native-global-exception-handler';
setJSExceptionHandler((error, isFatal) => {
console.log('JS Exception:', error);
if (isFatal) {
// Show fallback UI or send a fatal report
} else {
// Log and continue
}
});import { setNativeExceptionHandler } from 'react-native-global-exception-handler';
setNativeExceptionHandler((errorString) => {
console.log('Native Exception:', errorString);
// Send to crash reporting service
}, {
forceAppToQuit: true,
callPreviouslyDefinedHandler: false,
});For more complete examples, see Basic Usage, Native Crash Handling, and the API Reference.
See the contributing guide to learn how to contribute to the repository and the development workflow.
This project is inspired by the original work in react-native-exception-handler created by its original authors and community of contributors. Many foundational ideas (global JS/native handler approach, restart patterns, native popup customization) originated there.
MIT
Made with β€οΈ for the React Native community