SDK guides

React

@fixback/react files a React error with its component stack — the part of your UI that was rendering when it was thrown — including the errors an error boundary catches, which React otherwise only logs.

The web SDK already files every uncaught error. React keeps two things from it:

  • The errors an error boundary catches. React shows the boundary's fallback and only logs the error, so it never reaches the page's error handlers — whether the boundary is yours, your router's, or a component library's.
  • The component stack. The stack frames say which function threw; the component stack says which component, inside which, inside which. React hands it to a boundary and to the root's error handlers, and nowhere else.

This package files both through the SDK's captureException, so the same dedup, limits, beforeSend and scrub apply, and one error is filed once. It works with React 18 and 19.

Install

shell
npm install @fixback/react

It brings @fixback/sdk with it and re-exports it whole. Import init from @fixback/react too, so your app and these components run the one SDK:

main.tsx
import { createRoot } from "react-dom/client";import { init, rootErrorHandlers } from "@fixback/react";init({ key: "pk_live_…" });createRoot(document.getElementById("root")!, rootErrorHandlers()).render(<App />);

Call init before the first render. An error thrown while the app first renders is then held until Fixback answers, rather than lost. Every init option is in the web SDK reference.

Root error handlers (React 19)

rootErrorHandlers() returns createRoot's three error options. Pass them to createRoot or hydrateRoot, and every error React reports to the root is filed with its component stack, without wrapping anything:

OptionWhat React reports thereFiled as
onCaughtErrorAn error some error boundary caught — yours or a library'sCaptured
onUncaughtErrorAn error no boundary caught; React unmounts the rootUncaught
onRecoverableErrorAn error React recovered from on its own, a hydration mismatch sayCaptured

Each files the error, then does what React would have done: it logs a caught error, and reports an uncaught or recoverable one to the page as an uncaught error would be. Pass your own handler for any of the three and it runs in place of React's default, after the error is filed:

tsx
createRoot(container, { identifierPrefix: "app-", ...rootErrorHandlers() });// Your own handler runs in place of React's default, after the error is filedcreateRoot(  container,  rootErrorHandlers({    onUncaughtError: (error, errorInfo) => showCrashScreen(error),  }),);

The error boundary

FixbackErrorBoundary catches an error thrown while rendering its children, files it with its component stack, and renders its fallback:

tsx
import { FixbackErrorBoundary } from "@fixback/react";<FixbackErrorBoundary  fallback={({ error, resetError }) => (    <div role="alert">      <p>The cart could not be shown.</p>      <button onClick={resetError}>Try again</button>    </div>  )}  onError={(error, componentStack) => console.warn(error)}  onReset={() => queryClient.resetQueries({ queryKey: ["cart"] })}>  <Cart /></FixbackErrorBoundary>;
  • fallback — an element, or a function of { error, componentStack, resetError }. Without one, the boundary renders nothing in its children's place.
  • onError(error, componentStack) — called once the error is filed.
  • onReset(error, componentStack) — called when the fallback calls resetError, before the children render again.

What it catches is filed Captured: your app caught it and showed its fallback.

One error, filed once

The SDK files one error object once. With a FixbackErrorBoundary and the root handlers both installed, React reports a caught error to each, and only the first is filed. An uncaught error is filed by onUncaughtError, then reported to the page, where the SDK's own listener hears it and files nothing more.

The component stack on the Issue

The Issue's Report tab shows the component stack under the error, innermost component first:

Component stack
at CartTotal (https://shop.example/assets/index.js:40:12)at section (<anonymous>)at Cart (https://shop.example/assets/index.js:12:3)at FixbackErrorBoundary (https://shop.example/assets/index.js:3:9)at App (https://shop.example/assets/index.js:88:1)

The Brief and the coding agent's prompt carry it too. It rides with the error's first report as componentStack: at most 50 components and 8 KB, each line's script URL scrubbed like a stack frame's, so no query string, credentials or token-bearing fragment leaves the page. beforeSend sees it as report.componentStack.

In a production build, React names components as your bundler minified them. A development build names them as you wrote them.