API reference
@fixback/react reference
@fixback/react. For a narrative walkthrough, see the React guide.Exports
import { init, // and every other export of @fixback/sdk rootErrorHandlers, FixbackErrorBoundary,} from "@fixback/react";init({ key: "pk_live_…" });createRoot(container, rootErrorHandlers()).render( <FixbackErrorBoundary fallback={<p>Something went wrong.</p>}> <App /> </FixbackErrorBoundary>,);rootErrorHandlers(options?)— React 19's root error options, filing every error React reports to the root — see below.FixbackErrorBoundary— an error boundary that files what it catches — see below.- Everything
@fixback/sdkexports —init,Fixback,LAUNCH_EVENTand its types — re-exported, so the app and these components run the one SDK. See the web SDK reference.
React 18 and 19 are peer dependencies. Both exports report through Fixback.captureException,
passing React's component stack as its componentStack option. Before init, they file nothing.
rootErrorHandlers(options?)
type RootErrorHandler = (error: unknown, errorInfo: { componentStack?: string | null }) => void;rootErrorHandlers(options?: { onCaughtError?: RootErrorHandler; onUncaughtError?: RootErrorHandler; onRecoverableError?: RootErrorHandler;}): { onCaughtError: RootErrorHandler; onUncaughtError: RootErrorHandler; onRecoverableError: RootErrorHandler;};| Handler | Files | Then, unless you pass your own |
|---|---|---|
onCaughtError | An error a boundary caught, handled: true — Captured | Logs it with console.error, as React does |
onUncaughtError | An error no boundary caught, handled: false — Uncaught | Reports it to the page with reportError, as React does |
onRecoverableError | An error React recovered from, handled: true — Captured | Reports it to the page with reportError, as React does |
A handler you pass in options is called after the error is filed, with the same
arguments, in place of React's default. Spread the result into createRoot or hydrateRoot with your other options. React 18 reads only onRecoverableError.
FixbackErrorBoundary
| Prop | Type | Description |
|---|---|---|
children | ReactNode | The tree it guards. |
fallback | ReactNode | (props: FallbackProps) => ReactNode | What renders once a child throws. Without one, nothing renders in the children's place. |
onError | (error: unknown, componentStack: string) => void | Called once the error is filed. |
onReset | (error: unknown, componentStack: string | null) => void | Called when the fallback calls resetError, before the children render again. |
A fallback function is rendered with FallbackProps:
error— the error caught; anything can be thrown, not only anError.componentStack— the component stack React reported, ornullon the fallback's first render, before React hands it over.resetError()— clear the error and render the children again.
What the boundary catches is filed with handled: true — Captured.
The component stack
It rides with the error's first report as componentStack: the components innermost
first, one per line, at most 50 lines and 8 KB, each line's script URL scrubbed like a stack
frame's. beforeSend sees it as report.componentStack. One error object
is filed once, whichever of a boundary, a root handler and the SDK's window listener reaches the
SDK first — see One error, filed once.