crash-app-detection
v0.1.0
Published
This package provides two React components that help you detect client-side crashes and notify a Flutter host application (or any other bridge that re-uses the same contract).
Readme
Crash-aware React Error Boundaries
This package provides two React components that help you detect client-side crashes and notify a Flutter host application (or any other bridge that re-uses the same contract).
ErrorBoundary: A reusable class-based boundary with a customizable fallback and anonErrorhandler.ClientErrorBoundary: A thin wrapper that invokeswindow.flutter_inappwebview.callHandler('crashDetection', payload)before rendering a friendly fallback UI.
Installation
npm install crash-app-detectionThe package treats react and react-dom as peer dependencies, so be sure they are available in your app.
Usage
import { ClientErrorBoundary } from "crash-app-detection";
function App() {
return (
<ClientErrorBoundary>{/* Your app/components here */}</ClientErrorBoundary>
);
}You can customize the fallback UI or hook into errors yourself:
import { ErrorBoundary } from "crash-app-detection";
<ErrorBoundary
fallback={<div>Oops! Something went wrong.</div>}
onError={(error, info) => {
console.error("Boundary caught:", error, info);
}}
>
<MyComponent />
</ErrorBoundary>;Local development
npm install
npm run buildThe compiled output is emitted to dist/ with both JavaScript and TypeScript declaration files, ready to publish to npm.
