Sentry SDK Configuration Builder

Generate Sentry initialization code for React, Next.js, or Node.js

Create a Sentry.init() snippet with DSN, environment, release, traces sample rate, BrowserTracing and Session Replay integrations, replay sample rates, and a beforeSend filtering stub for React, Next.js, or Node.js apps.

Is the DSN a secret?

No. The DSN is a public client key that only allows sending events to your project, so it is safe to ship in browser bundles. Your auth token, used for source map uploads, is the secret you must keep server-side.

Sentry initialization tuned to your platform

Sentry is configured through a single Sentry.init() call, but the right package, integrations, and sample rates differ between a browser app and a Node service. This tool builds the snippet for your platform with the integrations that make sense there.

How it works

The init call takes a dsn that routes events to your project, plus environment and release tags that let you filter and attribute errors to a deploy. Integrations extend the SDK: browserTracingIntegration automatically instruments page loads and navigations for performance data, while replayIntegration records DOM mutations into a session replay. Both are browser-only, so the builder omits them for Node platforms.

Sampling is controlled by rates between 0 and 1. tracesSampleRate is the fraction of transactions kept for performance monitoring. For replay there are two knobs: replaysSessionSampleRate captures a slice of all sessions, and replaysOnErrorSampleRate captures sessions that produced an error — usually set to 1.0 so every crash is recorded. Finally, beforeSend is a hook invoked on each event; returning the event sends it, returning null drops it, which is the standard way to filter benign noise or scrub sensitive fields.

Tips and example

Keep the traces rate low in production to protect quota, and rely on the on-error replay rate to guarantee crashes are captured. A React setup:

import * as Sentry from "@sentry/react";

Sentry.init({
  dsn: "https://[email protected]/0",
  environment: "production",
  release: "[email protected]",
  integrations: [Sentry.browserTracingIntegration(), Sentry.replayIntegration()],
  tracesSampleRate: 0.1,
  replaysSessionSampleRate: 0.1,
  replaysOnErrorSampleRate: 1.0,
});

Upload source maps in CI with your Sentry auth token so stack traces map back to readable source instead of minified bundles.