Skip to main content

Installation

Install the package​

# npm
npm install unified-error-handling

# yarn
yarn add unified-error-handling

The core has zero production dependencies, so this single install adds nothing else to your tree.

Install the SDK for the adapter you use​

Service SDKs are not bundled. Each adapter loads its SDK with a dynamic import() at runtime, so you install only the one(s) you actually use. The built-in console adapter and any custom adapter need no extra package.

AdapterInstall
console— (built-in)
custom— (you provide the callbacks)
sentryyarn add @sentry/browser
firebaseUnavailable in package 2.1.1; installing firebase does not supply the imported firebase/crashlytics subpath.
datadogyarn add @datadog/browser-rum @datadog/browser-logs
bugsnagyarn add @bugsnag/js
rollbaryarn add rollbar
logrocketyarn add logrocket
raygunyarn add raygun4js
appcenteryarn add appcenter-crashes appcenter-analytics

If you call useAdapter('sentry') without @sentry/browser installed, the library throws a clear error telling you exactly what to install — and preserves the original module-resolution error as the thrown error's cause.

React (optional)​

The React layer lives at the unified-error-handling/react subpath. React 19+ is an optional peer dependency — the core never imports it:

{
"peerDependencies": {
"react": ">=19.0.0",
"react-dom": ">=19.0.0"
}
}

If you do not use React, ignore the subpath entirely; nothing React-related reaches your bundle.

Entry points​

// Core — works in any framework or vanilla JS / Node.js
import { initialize, captureError, useAdapter } from 'unified-error-handling';

// React layer — only if you use React
import { ErrorBoundary, useErrorHandler } from 'unified-error-handling/react';

Both ESM and CommonJS builds ship, along with full TypeScript declarations.

Next step​

Continue to the Quick Start.