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
npm install @fixback/reactIt 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:
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:
| Option | What React reports there | Filed as |
|---|---|---|
onCaughtError | An error some error boundary caught — yours or a library's | Captured |
onUncaughtError | An error no boundary caught; React unmounts the root | Uncaught |
onRecoverableError | An error React recovered from on its own, a hydration mismatch say | Captured |
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:
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:
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 callsresetError, 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:
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.