Sentry provides first-class JavaScript SDK support for browsers, Node.js, and every major framework. All packages live under theDocumentation Index
Fetch the complete documentation index at: https://sentrydocs.dev/llms.txt
Use this file to discover all available pages before exploring further.
@sentry npm scope.
Choose your package
@sentry/browser
Vanilla browser apps and any framework not listed here.
@sentry/node
Node.js servers, scripts, and serverless functions.
@sentry/nextjs
Next.js apps (App Router and Pages Router). Instruments both client and server.
@sentry/react
React apps. Adds
ErrorBoundary and component stack traces.@sentry/vue
Vue 3 (and Vue 2) applications.
@sentry/angular
Angular applications. Instruments the Angular ErrorHandler.
Installation
- Browser
- Node.js
- Next.js
- React
- Vue
- Angular
Basic initialization
CallSentry.init() as early as possible — before any other application code runs.
For Node.js, import
instrument.js at the very top of your entry point using --import ./instrument.js (ESM) or require('./instrument.js') (CJS) so Sentry initializes before any other modules load.Capturing errors
Automatic capture
Once initialized, Sentry automatically captures unhandled exceptions and promise rejections. No additional code is needed for those.Manual capture
Capture a message
"fatal", "error", "warning", "info", or "debug".
Setting context
Context enriches events so you can filter and search in Sentry.Breadcrumbs
Breadcrumbs are a trail of events captured before an error occurs. Sentry automatically records navigation, console output, XHR requests, and DOM clicks. You can also add custom breadcrumbs:Performance monitoring
Use transactions and spans to measure performance across operations.fetch, XMLHttpRequest, and browser navigation, include the BrowserTracing integration (built into @sentry/browser in SDK v8+):
React error boundary
Wrap components withErrorBoundary to catch rendering errors and display a fallback UI:
onError callback to run custom logic when the boundary catches:
Filtering events with beforeSend
UsebeforeSend to inspect, modify, or drop events before they leave the browser:
null to drop the event entirely. Return the (modified) event to send it.