Source Maps
Upload your source maps to Sentry to enable readable stack traces in your errors.
@sentry/nextjs
will generate and upload source maps automatically. You must have source maps enabled in order to have readable stack traces.
The easiest way to configure uploading source maps is by using the Sentry Wizard.
The @sentry/nextjs
SDK uses the Sentry webpack plugin under the hood to upload source maps. See the Build Options page and the Sentry webpack plugin documentation for more details. If you are using Vercel, then you can also use the Vercel integration to upload source maps during deployments automatically.
Note: Source maps are only generated and uploaded during production builds (next build
). Development builds (next dev
) do not generate source maps for upload.
See how uploading source maps lets you see the exact line of code that caused an error:
If you installed the SDK manually or the wizard failed, follow the steps below to manually configure source maps upload.
To automatically upload source maps, you need to provide your Sentry auth token, organization, and project slugs in your Next.js configuration:
Make sure you add your auth token to your CI, if you are using one to deploy your application.
Add your auth token to your environment:
.env.local
SENTRY_AUTH_TOKEN=sntrys_YOUR_TOKEN_HERE
Configure source map behavior using the source maps options in your Next.js config:
next.config.js
const { withSentryConfig } = require("@sentry/nextjs");
module.exports = withSentryConfig(
{
// your existing Next.js config
},
{
org: "example-org",
project: "example-project",
authToken: process.env.SENTRY_AUTH_TOKEN,
sourcemaps: {
disable: false, // Enable source maps (default: false)
assets: ["**/*.js", "**/*.js.map"], // Specify which files to upload
ignore: ["**/node_modules/**"], // Files to exclude
deleteSourcemapsAfterUpload: true, // Security: delete after upload
},
},
);
Important: The Sentry SDK doesn't yet fully support Turbopack production builds (next build --turbopack
) as Turbopack production builds are still in alpha.
- Turbopack dev mode (
next dev --turbopack
) is fully supported for Next.js 15.3.0+ - Turbopack production builds are not currently supported for source map upload
- If you're using Turbopack, remove the
--turbo
flag for production builds until full support is available
Check the latest information on Sentry's support for Turbopack on GitHub.
If you're experiencing issues with source maps, see Troubleshooting Source Maps.
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").