Sentry for Next.js
Official Sentry SDK for error tracking and performance monitoring in Next.js apps.
3. Used by agents' projects
Dependency in 99 public GitHub projects set up for AI coding agents that we scanned (1.6%).
4. Agent access
Agent skills for this library in the skills catalog; community skills are written by others, read them before you install.
sentry.io/llms.txtFrom the package registry and GitHub, checked daily. Tap a verdict to see its source.How we checkedReport an error
What Sentry for Next.js does
@sentry/nextjs is the Next.js entry in Sentry's official JavaScript SDK repository. It follows the same install-then-<code>Sentry.init</code> pattern as its sibling SDKs and reports to a Sentry project, where Sentry says errors, logs, replays and spans are "all connected by the same trace".
Sentry for Next.js popularity
Gid Score measures public popularity and activity, not quality. How the Gid Score is calculated
How Sentry for Next.js is used
- Sentry for Next.js is a dependency in 99 of the 6,258 public GitHub projects set up for AI coding agents that we scanned (2.0% of the 4,867 JavaScript/TypeScript ones), #4 of 121 in logging, monitoring and analytics.
- Counting the projects our scan samples by dependency (Solana 3,067, Ethereum and EVM 1,774, 3D and games 3,130, agent frameworks and SDKs 13,750), it appears in 260; those are left out of every share on this page.
- The most used alternative in our scan is Vercel Speed Insights (109 projects).
- Projects that use it most often also use Next.js (98.0%), clsx (80.8%), Tailwind Merge (77.8%).
By coding agent
Often used with
Sentry for Next.js in practice
Strengths
Sentry's site lists a wizard for Next.js: <code>npx @sentry/wizard@latest -i nextjs</code>. In the site's words, "it's really just one command".
Release 11.6.0 adds <code>@sentry/nextjs/cloudflare</code>. It exports <code>withSentry</code> for the Worker entry, for example OpenNext's <code>.open-next/worker.js</code>. The release notes say this gives a Next.js app on Workers the same spans it gets on Node.js.
Sentry's site says errors, logs, replays, spans, profiles and metrics are "all connected by the same trace", and adds "That's kind of our thing." Its examples are debugging 500s and replaying <code>fetch()</code> failures.
The browser's <code>performance.now()</code> clock stops while a device sleeps, so span timestamps recorded afterwards could be too early. Per the 11.6.0 notes, the SDK now detects this drift and corrects its time origin.
Watch out for
The SDK reports to Sentry. Before anything is captured, you create a project and copy its key from the Client Keys (DSN) settings.
Sentry's JavaScript snippet sets <code>tracesSampleRate: 1.0</code>. Its own comment recommends adjusting this in production or using <code>tracesSampler</code>.
The README's version policy ties fixes and features for older versions to community demand and usage. It does not state a support period.
The init pattern every Sentry JS SDK follows (shown in the README with @sentry/browser)
import * as Sentry from '@sentry/browser';
Sentry.init({
dsn: '__DSN__',
// ...
});
Sentry.captureMessage('Hello, world!');More about Sentry for Next.js
Funding
- Own page: https://sentry.io/pricing/
- Own page: https://sentry.io/
Agent Skills for it
- nextjs-app-router-patterns: Master Next.js 14+ App Router with Server Components, streaming, parallel routes, and advanced data fetching. Use when building Next.js appl
- nextjs-developer: Use when building Next.js 14+ applications with App Router, server components, or server actions. Invoke to configure route handlers, implem
- nextjs-developer: Use when building Next.js 14+ applications with App Router, server components, or server actions. Invoke for full-stack features, performanc
- nextjs-on-cloudflare: Build, migrate, and deploy Next.js apps on Cloudflare Workers with vinext. Use when starting a Next.js project on Cloudflare, moving an exis
- nextjs-mastery: Next.js 14+ App Router patterns including RSC, ISR, middleware, parallel routes, and data fetching
- nextjs-app-router-patterns: Master Next.js 14+ App Router with Server Components, streaming, parallel routes, and advanced data fetching. Use when building Next.js appl
Packages around it
- next: Next.js framework
- clsx: className builder
- tailwind-merge: Tailwind class merging
- react: UI library
- lucide-react: Icon set
- class-variance-authority: Component variants
More in Logging, monitoring and analytics
Alternatives
Sentry for Next.js This page
Measure web performance metrics and get recommendations for improvement.
Get started
Install it.
npm install @sentry/nextjsRules for your agent
## Sentry for Next.js
- Start setup with the wizard, `npx @sentry/wizard@latest -i nextjs`.
- Initialize the SDK with the DSN from the Sentry project's Client Keys (DSN) settings. Never invent a DSN.
- Set the environment through a `SENTRY_ENVIRONMENT` variable or in the SDK config, so alerts and issue filters can work per environment.
- Do not ship `tracesSampleRate: 1.0` to production unchanged. Lower it or use `tracesSampler`, as Sentry's snippets advise.
- For Next.js on Cloudflare Workers (for example OpenNext), wrap the Worker entry with `withSentry` from `@sentry/nextjs/cloudflare` and read the DSN from `env.SENTRY_DSN`.
- For a monolithic codebase, the docs recommend separate Sentry projects for backend and frontend.