Skip to content

Source Maps | Sentry for Next.js

Source URL: https://docs.sentry.io/platforms/javascript/guides/nextjs/sourcemaps

Source maps translate minified production code back to your original source, giving you readable stack traces instead of cryptic line numbers.

The SDK handles this automatically. When you run next build, source maps are generated and uploaded to Sentry. No extra configuration needed if you used the Sentry Wizard.

Source maps are only uploaded during production builds (next build). Development builds (next dev) don’t generate uploads.

Deploying with Vercel? You can also use the Vercel integration for automatic uploads during deployment.

See how source maps transform your error reports:

If you installed the SDK manually or the wizard didn’t complete, configure source map uploads:

Add your Sentry auth token to your environment. Make sure to also add it to your CI.

.env.local

Terminal window
SENTRY_AUTH_TOKEN=___ORG_AUTH_TOKEN___

Add withSentryConfig to your Next.js config with your org, project, and auth token.

With Turbopack (Next.js 15+ default), source maps upload after the build completes.

Requires @sentry/nextjs@10.13.0+ and next@15.4.1+.

next.config.ts

import type { NextConfig } from "next";
import { withSentryConfig } from "@sentry/nextjs";
const nextConfig: NextConfig = {
// your existing Next.js config
};
export default withSentryConfig(nextConfig, {
org: "___ORG_SLUG___",
project: "___PROJECT_SLUG___",
authToken: process.env.SENTRY_AUTH_TOKEN,
});
OptionDefaultDescription
sourcemaps.deleteSourcemapsAfterUploadtrueDelete client-side source maps after upload. Server source maps are kept for runtime error reporting.
widenClientFileUploadfalseUpload dependency source maps to fix [native code] frames

See Build Options for all available options.

If you’re using Webpack instead of Turbopack, source maps are uploaded during the build (not after). The configuration is the same, but you have additional options:

  • Post-build upload mode: Set useRunAfterProductionCompileHook: true to upload after build (requires Next.js 15.4.1+)
  • Advanced plugin options: Use webpack.unstable_sentryWebpackPluginOptions to pass options to the Sentry Webpack Plugin

See Webpack Setup for complete Webpack configuration.

If stack traces show minified code, check that SENTRY_AUTH_TOKEN is set in your CI environment.

See Troubleshooting Source Maps for detailed debugging steps.