API reference

@fixback/react reference

The complete API of @fixback/react. For a narrative walkthrough, see the React guide.

Exports

tsx
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/sdk exports — init, Fixback, LAUNCH_EVENT and 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?)

ts
type RootErrorHandler = (error: unknown, errorInfo: { componentStack?: string | null }) => void;rootErrorHandlers(options?: {  onCaughtError?: RootErrorHandler;  onUncaughtError?: RootErrorHandler;  onRecoverableError?: RootErrorHandler;}): {  onCaughtError: RootErrorHandler;  onUncaughtError: RootErrorHandler;  onRecoverableError: RootErrorHandler;};
HandlerFilesThen, unless you pass your own
onCaughtErrorAn error a boundary caught, handled: true — CapturedLogs it with console.error, as React does
onUncaughtErrorAn error no boundary caught, handled: false — UncaughtReports it to the page with reportError, as React does
onRecoverableErrorAn error React recovered from, handled: true — CapturedReports 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

PropTypeDescription
childrenReactNodeThe tree it guards.
fallbackReactNode | (props: FallbackProps) => ReactNodeWhat renders once a child throws. Without one, nothing renders in the children's place.
onError(error: unknown, componentStack: string) => voidCalled once the error is filed.
onReset(error: unknown, componentStack: string | null) => voidCalled 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 an Error.
  • componentStack — the component stack React reported, or null on 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.