React guide
React error tracking
Errilo receives your React errors from the official @sentry/react SDK: rendering errors with their component stack, caught by an error boundary or not. Already on Sentry? Only the DSN changes.
Errilo is in private beta. This guide describes the setup our compatibility suite tests today.
What gets caught
- A component that throws while rendering, with no error boundary around it: React unmounts the app and reports the error to
onUncaughtError. - A component that throws while rendering inside
Sentry.ErrorBoundary: React reports it toonCaughtError, and the boundary shows its fallback. - The same error with
Sentry.ErrorBoundaryalone, without theonCaughtErrorhook: the boundary captures it itself.
Our compatibility suite builds a React 19 app with Vite 8 (a production build), serves it, opens it in Chromium and triggers each of these three cases, for every SDK version listed below. Each error reaches Errilo once, with the React component stack.
Not covered by our suite: React 18 and earlier, server rendering, router integrations, and tracing, replay and profiling. Errilo doesn’t store tracing, replay or profiling data: leave them off.
Setup
Install the SDK:
npm install @sentry/reactThen initialize it before rendering, and give createRoot the three React 19 error hooks. This is the file from the React tab of the Errilo app, and the one our suite runs. If you already have a Sentry setup, keep it and change the DSN.
import * as Sentry from "@sentry/react";
import { createRoot } from "react-dom/client";
import { App } from "./App";
Sentry.init({
dsn: "https://<key>@ingest.errilo.com/<project>",
});
// React 19: report rendering errors with their component stack
createRoot(document.getElementById("root")!, {
onUncaughtError: Sentry.reactErrorHandler(),
onCaughtError: Sentry.reactErrorHandler(),
onRecoverableError: Sentry.reactErrorHandler(),
}).render(<App />);Replace the DSN with the one of your Errilo project. With Vite, the DSN is part of the bundle at build time: rebuild after changing it.
Show a fallback with ErrorBoundary
Sentry.ErrorBoundary shows a fallback instead of an empty page when a component below it throws while rendering:
import * as Sentry from "@sentry/react";
export function Page() {
return (
<Sentry.ErrorBoundary fallback={<p>Something went wrong.</p>}>
<Dashboard />
</Sentry.ErrorBoundary>
);
}With the three hooks above, the error is reported once, by onCaughtError: our suite checks that the boundary doesn’t report it a second time. Without onCaughtError, the boundary reports it itself, also once.
Readable stack traces
In production, a React stack trace points to your minified bundle. The Sentry build plugins upload your source maps at build time, and Errilo implements the same upload API: give it Errilo’s address and an Errilo token in four build variables (SENTRY_URL, SENTRY_ORG, SENTRY_PROJECT, SENTRY_AUTH_TOKEN, see the source maps guide), and frames point to your own files, lines and function names. No organization, project, token or URL goes in the plugin options: the variables are enough.
What our suite checks is the plugin and the symbolication, not a full React app: it builds a small bundle with each plugin version, uploads its source maps and reads the error in Errilo (original file, line, line of code and function name).
Vite (@sentry/vite-plugin). Source maps must be generated, and hidden keeps the sourceMappingURL comment out of your files:
import { sentryVitePlugin } from "@sentry/vite-plugin";
import { defineConfig } from "vite";
export default defineConfig({
build: {
sourcemap: "hidden", // generate the source maps
},
plugins: [sentryVitePlugin()],
});@sentry/vite-plugin 11.12.0 with Vite 8 has a defect: the plugin uploads a copy of your file with one more line than the file you serve, so the source map is shifted by one line, and the frames of the bundle are reported as @sentry/core instead of your file. The error still arrives and Errilo shows no symbolication error. Until it is fixed, use @sentry/vite-plugin 5.4.1: its upload is symbolicated.
Webpack (@sentry/webpack-plugin). Webpack 5, in production mode, with source maps generated and hidden:
const { sentryWebpackPlugin } = require("@sentry/webpack-plugin");
module.exports = {
mode: "production",
devtool: "hidden-source-map", // generate the source maps
plugins: [sentryWebpackPlugin()],
};Create React App doesn’t let you add a Webpack plugin: you need CRACO, or to eject. Our suite tests the Webpack plugin in a plain Webpack 5 build, not a Create React App or CRACO app.
| Plugin | Version | Bundler | Browser error |
|---|---|---|---|
@sentry/webpack-plugin | 4.9.1 | Webpack 5 | Symbolicated |
@sentry/webpack-plugin | 5.4.1 | Webpack 5 | Symbolicated |
@sentry/webpack-plugin | 11.12.0 | Webpack 5 | Symbolicated |
@sentry/vite-plugin | 4.9.1 | Vite 8 | Symbolicated |
@sentry/vite-plugin | 5.4.1 | Vite 8 | Symbolicated |
@sentry/vite-plugin | 11.12.0 | Vite 8 | Not symbolicated: frames reported as @sentry/core |
Keep the SDK light
Errilo reads errors and user feedback, and drops traces, profiles, logs and sessions. Don’t set tracesSampleRate or any profiling option, and turn on the build options below: your bundle gets smaller and your users’ browsers send less. Breadcrumbs, release, source maps and user feedback aren’t affected. The same bundleSizeOptimizations option exists in sentryWebpackPlugin(). In a React app, tracing only enters the bundle if you add browserTracingIntegration(): don’t. Details and measured sizes in the migration guide.
plugins: [
sentryVitePlugin({
// …
bundleSizeOptimizations: {
excludeDebugStatements: true,
excludeTracing: true,
},
}),
],Tested versions
| Major version | Tested version |
|---|---|
| v9 | @sentry/react:9.47.2 |
| v10 | @sentry/react:10.78.0 |
| v11 | @sentry/react:11.12.0 |
With React 19, in a Vite 8 production build opened in Chromium. Tested on SDK 9 to 11, and nothing else: React 18 and earlier, server rendering and router integrations aren’t covered by our suite yet.