Source Maps

Upload your source maps to Sentry to enable readable stack traces in your errors.

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.

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
Copied
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.

next.config.ts
Copied
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.

Was this helpful?
Help improve this content
Our documentation is open source and available on GitHub. Your contributions are welcome, whether fixing a typo (drat!) or suggesting an update ("yeah, this would be better").