Skip to content

Nextjs source map doc updates #14433

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 8 commits into from
Jul 24, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 2 additions & 3 deletions docs/platforms/javascript/common/sourcemaps/index.mdx
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
---
title: Source Maps
sidebar_order: 3
description: "Upload your source maps to Sentry to enable readable stack traces in your errors, along with other numerous benefits. Learn more here."
description: "Upload your source maps to Sentry to enable readable stack traces in your errors."
---

<PlatformContent includePath="sourcemaps/primer" />
Expand All @@ -11,5 +11,4 @@ description: "Upload your source maps to Sentry to enable readable stack traces
## Additional Resources

- [Using sentry-cli to Upload Source Maps](/cli/releases/#sentry-cli-sourcemaps)
- [4 Reasons Why Your Source Maps Are Broken](https://blog.sentry.io/2018/10/18/4-reasons-why-your-source-maps-are-broken)
- [Debug Your Node.js Projects with Source Maps](https://blog.sentry.io/2019/02/20/debug-node-source-maps)
- [4 Reasons Why Your Source Maps Are Broken](https://blog.sentry.io/2018/10/18/4-reasons-why-your-source-maps-are-broken)
69 changes: 69 additions & 0 deletions platform-includes/sourcemaps/overview/javascript.nextjs.mdx
Original file line number Diff line number Diff line change
@@ -0,0 +1,69 @@
### Manual Configuration
If you installed the SDK manually or the wizard failed, follow the steps below to manually configure source maps upload.

#### 1. 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:

<OrgAuthTokenNote />

**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:

```bash {filename:.env.local}
SENTRY_AUTH_TOKEN=___ORG_AUTH_TOKEN___
```

```javascript {filename:next.config.js}
const { withSentryConfig } = require("@sentry/nextjs");

module.exports = withSentryConfig(
{
// your existing Next.js config
},
{
org: "___ORG_SLUG___",
project: "___PROJECT_SLUG___",
authToken: process.env.SENTRY_AUTH_TOKEN,
}
);
```

#### 2. Source Map Options
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should we mention somewhere here that everything below is optional?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good call!


Configure source map behavior using the [source maps options](/platforms/javascript/guides/nextjs/configuration/build/#source-maps-options) in your Next.js config:

```javascript {11-16} {filename:next.config.js}
const { withSentryConfig } = require("@sentry/nextjs");

module.exports = withSentryConfig(
{
// your existing Next.js config
},
{
org: "___ORG_SLUG___",
project: "___PROJECT_SLUG___",
authToken: process.env.SENTRY_AUTH_TOKEN,
sourcemaps: {
disable: false, // Enable source maps (default: false)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
disable: false, // Enable source maps (default: false)
disable: false, // Disable 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
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We should mention that this is true by default

},
}
);
```
### Turbopack Considerations

**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](https://github.com/getsentry/sentry-javascript/issues/8105).

### Troubleshooting

If you're experiencing issues with source maps, see [Troubleshooting Source Maps](/platforms/javascript/guides/nextjs/sourcemaps/troubleshooting_js/).
12 changes: 10 additions & 2 deletions platform-includes/sourcemaps/primer/javascript.nextjs.mdx
Original file line number Diff line number Diff line change
@@ -1,3 +1,11 @@
`@sentry/nextjs` will generate and upload source maps automatically, in order to enable errors to have readable stack traces.
`@sentry/nextjs` will generate and upload source maps automatically. You must have source maps enabled in order to have readable stack traces.

To upload source maps, the `@sentry/nextjs` SDK uses the Sentry webpack plugin under the hood. See the [Build Options](../configuration/build/#source-maps-options) page and the Sentry [webpack plugin documentation](https://www.npmjs.com/package/@sentry/webpack-plugin) for more details. If you are using Vercel, then you can also use the [Vercel integration](/organization/integrations/deployment/vercel/) to upload source maps during deployments automatically.
The easiest way to configure uploading source maps is by using the [Sentry Wizard](/platforms/javascript/guides/nextjs/#step-1-install).

The `@sentry/nextjs` SDK uses the Sentry webpack plugin under the hood to upload source maps. See the [Build Options](../configuration/build/#source-maps-options) page and the Sentry [webpack plugin documentation](https://www.npmjs.com/package/@sentry/webpack-plugin) for more details. If you are using Vercel, then you can also use the [Vercel integration](/organization/integrations/deployment/vercel/) 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:

<Arcade src="https://demo.arcade.software/OFrHpZUU739XKR8qUiEP?embed" />