Guide
Next.js (App Router)
Next.js uses @sentry/nextjs, which instruments client, server and edge runtimes. Four small files and a config wrapper.
The files
// sentry.server.config.ts (and sentry.edge.config.ts, same shape)
import * as Sentry from '@sentry/nextjs';
Sentry.init({
dsn: process.env.SENTRY_DSN || 'https://<publicKey>@jentry.app/<projectId>',
enabled: process.env.NODE_ENV === 'production',
tracesSampleRate: 0.1,
});// src/instrumentation.ts
import * as Sentry from '@sentry/nextjs';
export async function register() {
if (process.env.NEXT_RUNTIME === 'nodejs') await import('../sentry.server.config');
if (process.env.NEXT_RUNTIME === 'edge') await import('../sentry.edge.config');
}
export const onRequestError = Sentry.captureRequestError;// src/instrumentation-client.ts
import * as Sentry from '@sentry/nextjs';
Sentry.init({ dsn: process.env.NEXT_PUBLIC_SENTRY_DSN || 'https://<publicKey>@jentry.app/<projectId>' });
export const onRouterTransitionStart = Sentry.captureRouterTransitionStart;// next.config.ts
import { withSentryConfig } from '@sentry/nextjs';
export default withSentryConfig(nextConfig, { silent: true, widenClientFileUpload: true });Add a global-error.tsx that calls Sentry.captureException(error) in a useEffect so App-Router render crashes are reported.
Tip: use separate jentry projects for client and server (two DSNs) — browser noise and server errors triage very differently.
Try jentry free
Hosted error tracking & performance monitoring. Works with your Sentry SDKs — send your first event in minutes.