Your Production App Has No Error Monitoring: A 30-Minute Sentry Setup for Next.js
We run a lot of client projects with Sentry. Our own marketing site had none. We found out when a colleague's Safari crashed on our homepage and we had zero record of it (). This is the setup we added the same day.
1. Install
bash npm install @sentry/nextjs
Create a project in Sentry (platform: Next.js) and copy the DSN from Settings → Client Keys. The DSN is public by design: it only lets a client send events, so it is safe in the browser bundle.
2. Client side
Next.js 15 loads in the browser before your app code.
ts import * as Sentry from '@sentry/nextjs';
Sentry.init({ dsn: process.env.NEXT_PUBLIC_SENTRY_DSN, enabled: process.env.NODE_ENV === 'production', environment: process.env.NEXT_PUBLIC_VERCEL_ENV, tracesSampleRate: 0.05, sendDefaultPii: false, ignoreErrors: [ 'ResizeObserver loop limit exceeded', 'ResizeObserver loop completed with undelivered notifications', ], });
export const onRouterTransitionStart = Sentry.captureRouterTransitionStart;
keeps local development out of your quota. keeps performance data at 5% of page loads while errors still go through at 100%.
3. Server and edge
runs once per server instance:
ts import * as Sentry from '@sentry/nextjs';
export async function register() { if (process.env.NEXT_RUNTIME === 'nodejs' || process.env.NEXT_RUNTIME === 'edge') { Sentry.init({ dsn: process.env.NEXT_PUBLIC_SENTRY_DSN, enabled: process.env.NODE_ENV === 'production', tracesSampleRate: 0.05, }); } }
export const onRequestError = Sentry.captureRequestError;
is the hook that reports errors thrown in Server Components, route handlers and middleware.
4. Error boundaries
This step gets skipped most often. Next.js catches render errors in , shows your fallback, and the error never reaches Sentry unless you send it:
tsx 'use client'; import * as Sentry from '@sentry/nextjs'; import { useEffect } from 'react';
export default function ErrorBoundary({ error }: { error: Error }) {
useEffect(() => { Sentry.captureException(error); }, [error]);
return
Do the same in , which catches errors in the root layout. Our old rendered a 404 page and swallowed the error. Every crash looked like a missing page.
5. Build config
js const { withSentryConfig } = require('@sentry/nextjs/config');
module.exports = withSentryConfig(nextConfig, { org: 'your-org', project: 'your-project', authToken: process.env.SENTRY_AUTH_TOKEN, sourcemaps: { disable: !process.env.SENTRY_AUTH_TOKEN }, telemetry: false, });
Without the build skips source map upload and your stack traces stay minified. Add the token in Vercel once you start reading errors seriously.
6. Test it
Deploy a preview and run this in the browser console:
js setTimeout(() => { throw new Error('Sentry setup test'); }, 0);
The matters. An error thrown directly in the console does not reach the global handler. Within a few seconds the issue should appear in Sentry.
7. Route alerts to a human
The default alert emails the account owner. We created the Sentry account on an email address that forwards into a Slack channel, so new issues land where the team already reads. Any channel works, as long as someone looks at it every day.
What it caught on day three
Three days after setup Sentry reported an unhandled error on : . The breadcrumbs showed the real story. Our CMS had answered with an HTML error page, the fetch helper called on it, and a cold server instance with no cached copy rendered a crash for the visitor.
Nobody had reported it. The fix took 20 minutes: retry 5xx responses twice with a short backoff, fail fast on 4xx, and put the status code in the error message so Sentry groups by cause.
Free plan budget
The free tier is enough for most marketing sites and early products if you:
- send all errors, sample traces at 1-5%,
- ignore known noise (, browser extensions),
- turn off session replay until you need it.
If your app already has thousands of errors a day and nobody knows where to start, that is a different job. We cover it in our .
FAQ
What services do we provide?
We specialize in creating innovative digital solutions including web development, mobile applications, CRM systems, and enterprise software. Our services are tailored to meet your specific business needs and drive growth.

Oleksii Stupak
CEO @ AleannLab
"Want to explore how we can help your business grow? Let's connect and discuss your project on LinkedIn."
Ready to discuss your project with us?




