with one click
sentry-react-core
// Initialize and configure Sentry in client-side React SPAs — DSN setup, instrument.js pattern, React 19 error hooks, integrations, releases, and tunneling.
// Initialize and configure Sentry in client-side React SPAs — DSN setup, instrument.js pattern, React 19 error hooks, integrations, releases, and tunneling.
[HINT] Download the complete skill directory including SKILL.md and all related files
| name | sentry-react-core |
| description | Initialize and configure Sentry in client-side React SPAs — DSN setup, instrument.js pattern, React 19 error hooks, integrations, releases, and tunneling. |
| tech_stack | ["react"] |
| language | javascript |
| capability | ["observability"] |
| version | Sentry JavaScript SDK unversioned |
| collected_at | "2025-01-01T00:00:00.000Z" |
Source: https://docs.sentry.io/platforms/javascript/guides/react/, https://docs.sentry.io/platforms/javascript/guides/react/configuration/, https://docs.sentry.io/platforms/javascript/guides/react/configuration/releases/
Initialize and configure @sentry/react for client-side React SPAs. Covers DSN setup, the mandatory instrument.js bootstrap pattern, React 19 error hooks (reactErrorHandler), key integrations (tracing, replay, feedback), release/environment binding, Redux integration, and ad-blocker tunneling.
onUncaughtError/onCaughtErrorDo not use for Next.js, Remix, Gatsby — those have dedicated SDKs with SSR support.
npm install @sentry/react --save
instrument.js (must import FIRST in your entry point)import * as Sentry from "@sentry/react";
Sentry.init({
dsn: "___PUBLIC_DSN___",
integrations: [
Sentry.browserTracingIntegration(),
Sentry.replayIntegration(),
],
tracesSampleRate: 1.0,
tracePropagationTargets: [/^\//, /^https:\/\/yourserver\.io\/api/],
replaysSessionSampleRate: 0.1,
replaysOnErrorSampleRate: 1.0,
});
// instrument.js MUST be the very first import
import "./instrument";
import App from "./App";
import { createRoot } from "react-dom/client";
const container = document.getElementById("app");
const root = createRoot(container);
root.render(<App />);
import "./instrument";
import * as Sentry from "@sentry/react";
import { createRoot } from "react-dom/client";
const root = createRoot(document.getElementById("app"), {
onUncaughtError: Sentry.reactErrorHandler((error, errorInfo) => {
console.warn("Uncaught error", error, errorInfo.componentStack);
}),
onCaughtError: Sentry.reactErrorHandler(),
onRecoverableError: Sentry.reactErrorHandler(),
});
root.render(<App />);
import * as Sentry from "@sentry/react";
<Sentry.ErrorBoundary fallback={<p>An error has occurred</p>}>
<YourApp />
</Sentry.ErrorBoundary>
Sentry.init() options| Option | Purpose |
|---|---|
dsn | Project DSN (required) |
release | Release version, e.g. "my-app@2.3.12" |
environment | "production", "staging", etc. |
tracesSampleRate | 0.0–1.0, fraction of transactions captured |
tracesSampler | Function for per-transaction sampling decisions |
tracePropagationTargets | URL regexes for sentry-trace header propagation |
replaysSessionSampleRate | Fraction of sessions recorded |
replaysOnErrorSampleRate | Replay rate for errored sessions |
sendDefaultPii | Send user IP and headers |
debug | Log SDK activity to console |
tunnel | Proxy events through /tunnel to evade ad blockers |
enableLogs | Capture structured logs via Sentry.logger |
integrations | Array of integrations or filter function |
Sentry.browserTracingIntegration() — automatic page-load/navigation tracingSentry.replayIntegration() — Session Replay recordingSentry.feedbackIntegration({colorScheme: "system"}) — user feedback widgetSentry.reactRouterV7BrowserTracingIntegration({...}) — React Router v7 instrumentationSentry.captureException(error) — manually report an exceptionSentry.captureMessage("msg") — manually report a messageSentry.startSpan({op, name}, callback) — wrap code in a custom spanSentry.reactErrorHandler() — factory for React 19 error hook callbacksSentry.logger.info/warn/error(msg, data) — structured log emissioninstrument.js MUST be the first import in your entry point, before React or any app code. Otherwise events may be missed.tunnel: "/tunnel" to route traffic through your own origin.npx @sentry/wizard@latest -i sourcemaps."project-name@version". Pre-register releases in Sentry to unlock commit-tracking and deployment notifications.History API navigation change. Sessions are auto-managed by BrowserSession integration.Sentry.createReduxEnhancer() and compose with existing enhancers.reactRouterV6BrowserTracingIntegration or reactRouterV7BrowserTracingIntegration instead of the generic browserTracingIntegration.