Issue
I receive Sentry events from my Next.js client and edge configs, but server-thrown errors do not appear in Sentry.
Applies To
All SaaS Customers and Self-Hosted Users
Next.js SDK
Error Monitoring
Resolution
@sentry/nextjs initializes separately per runtime. sentry.server.config.ts runs only in the Node.js runtime. Client and edge configs do not cover Node server code.
Confirm the failing code runs on the Node.js runtime. If the route or Server Component sets
runtime = "edge", Sentry usessentry.edge.config.ts, not the server config. Move the work to Node, or configure and test the edge SDK path instead.Confirm
instrumentation.tsloads the server config whenprocess.env.NEXT_RUNTIME === "nodejs", and thatsentry.server.config.tscallsSentry.initwith your DSN.For Next.js 15+ with
@sentry/nextjs8.28.0 or newer, exportonRequestError = Sentry.captureRequestErrorfrominstrumentation.tsso Server Components, middleware, and proxies report errors.If you catch errors in
error.tsx, API routes, or Server Actions and do not rethrow, callSentry.captureExceptionyourself. Next.js error boundaries and gracefultry/catchhide errors from the global handler.
Example instrumentation.ts shape:
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;
See the Next.js setup guide and capturing errors for full details.
