What is @sentry/nextjs?
The @sentry/nextjs package is a JavaScript SDK for Sentry that provides error tracking and performance monitoring specifically tailored for Next.js applications. It helps developers to automatically capture exceptions, track performance issues, and improve the reliability of their Next.js applications.
What are @sentry/nextjs's main functionalities?
Automatic Error Tracking
Automatically captures unhandled exceptions and errors in the Next.js application and sends them to Sentry for monitoring and analysis.
import * as Sentry from '@sentry/nextjs';
Sentry.init({ dsn: 'YOUR_DSN' });
Performance Monitoring
Enables performance monitoring to track the performance of server-side and client-side Next.js operations, providing insights into slow transactions and bottlenecks.
import * as Sentry from '@sentry/nextjs';
Sentry.init({
dsn: 'YOUR_DSN',
tracesSampleRate: 1.0
});
Custom Error Reporting
Allows developers to manually report custom errors or exceptions to Sentry, giving them control over what gets reported.
import * as Sentry from '@sentry/nextjs';
Sentry.captureException(new Error('Custom error message'));
Release Health Tracking
Tracks the health of releases by monitoring error rates and issues that affect end-users, helping developers to understand the impact of new releases.
import * as Sentry from '@sentry/nextjs';
Sentry.init({
dsn: 'YOUR_DSN',
release: 'my-project-name@1.0.0'
});
Other packages similar to @sentry/nextjs
bugsnag-js
Bugsnag provides error monitoring for JavaScript applications, including Next.js. It offers similar features to Sentry, such as automatic error detection, custom error reporting, and release tracking. However, Bugsnag's interface and integrations may differ from Sentry's.
raygun4js
Raygun offers real-time error tracking and crash reporting for JavaScript applications. It includes features like user tracking, performance monitoring, and deployment tracking. Raygun's focus on user-centric metrics and detailed diagnostics provides a different perspective compared to Sentry.
logrocket
LogRocket is a frontend application monitoring solution that combines session replay, performance monitoring, and error tracking. Unlike Sentry, which focuses on error and performance data, LogRocket provides insights into user interactions and experiences by recording user sessions.
Official Sentry SDK for Next.js

See the Official Sentry Next.js SDK Docs to get started.
Compatibility
Currently, the minimum supported version of Next.js is 13.2.0
.
Installation
To get started installing the SDK, use the Sentry Next.js Wizard by running the following command in your terminal or
read the Getting Started Docs:
npx @sentry/wizard@latest -i nextjs
The wizard will prompt you to log in to Sentry. After the wizard setup is completed, the SDK will automatically capture
unhandled errors, and monitor performance.
Custom Usage
To set context information or to send manual events, you can use @sentry/nextjs
as follows:
import * as Sentry from '@sentry/nextjs';
Sentry.setTag('user_mode', 'admin');
Sentry.setUser({ id: '4711' });
Sentry.setContext('application_area', { location: 'checkout' });
Sentry.addBreadcrumb({
message: '"Add to cart" clicked',
});
Sentry.captureException(new Error('Oh no.'));
Sentry.captureMessage('Hello, world!');
Links
9.39.0
Important Changes
- feat(browser): Add
afterStartPageloadSpan
hook to improve spanId assignment on web vital spans (#16893)
This PR adds a new afterStartPageloadSpan lifecycle hook to more robustly assign the correct pageload span ID to web vital spans, replacing the previous unreliable "wait for a tick" approach with a direct callback that fires when the pageload span becomes available.
- feat(nextjs): Client-side parameterized routes (#16934)
This PR implements client-side parameterized routes for Next.js by leveraging an injected manifest within the existing app-router instrumentation to automatically parameterize all client-side transactions (e.g. users/123
and users/456
now become become users/:id
).
- feat(node): Drop 401-404 and 3xx status code spans by default (#16972)
This PR changes the default behavior in the Node SDK to drop HTTP spans with 401-404 and 3xx status codes by default to reduce noise in tracing data.
Other Changes
- feat(core): Prepend vercel ai attributes with
vercel.ai.X
(#16908)
- feat(nextjs): Add
disableSentryWebpackConfig
flag (#17013)
- feat(nextjs): Build app manifest (#16851)
- feat(nextjs): Inject manifest into client for turbopack builds (#16902)
- feat(nextjs): Inject manifest into client for webpack builds (#16857)
- feat(node-native): Add option to disable event loop blocked detection (#16919)
- feat(react-router): Ensure http.server route handling is consistent (#16986)
- fix(core): Avoid prolonging idle span when starting standalone span (#16928)
- fix(core): Remove side-effect from
tracing/errors.ts
(#16888)
- fix(core): Wrap
beforeSendLog
in consoleSandbox
(#16968)
- fix(node-core): Apply correct SDK metadata (#17014)
- fix(react-router): Ensure that all browser spans have
source=route
(#16984)
Work in this release was contributed by @janpapenbrock. Thank you for your contribution!