# Source Maps | Sentry for Next.js

`@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](https://docs.sentry.io/platforms/javascript/guides/nextjs.md#step-1-install).

The `@sentry/nextjs` SDK uses the Sentry webpack plugin under the hood to upload source maps. See 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](https://docs.sentry.io/organization/integrations/deployment/vercel.md) 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:

### [Manual Configuration](https://docs.sentry.io/platforms/javascript/guides/nextjs/sourcemaps.md#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](https://docs.sentry.io/platforms/javascript/guides/nextjs/sourcemaps.md#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:

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

```bash
SENTRY_AUTH_TOKEN=___ORG_AUTH_TOKEN___
```

#### [2. \[Optional\] Customize Source Map Options](https://docs.sentry.io/platforms/javascript/guides/nextjs/sourcemaps.md#2-optional-customize-source-map-options)

Configure source map behavior in your Next.js config:

`next.config.js`

```javascript
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, // Source maps are enabled by default
      assets: ["**/*.js", "**/*.js.map"], // Specify which files to upload
      ignore: ["**/node_modules/**"], // Files to exclude
      deleteSourcemapsAfterUpload: true, // Security: delete after upload
    },

  },
);
```

### [Turbopack Considerations](https://docs.sentry.io/platforms/javascript/guides/nextjs/sourcemaps.md#turbopack-considerations)

Sourcemaps for Turbopack production builds are supported starting with `@sentry/nextjs@10.13.0`. The minimum required Next.js version is `next@15.4.1`.

### [Troubleshooting](https://docs.sentry.io/platforms/javascript/guides/nextjs/sourcemaps.md#troubleshooting)

If you're experiencing issues with source maps, see [Troubleshooting Source Maps](https://docs.sentry.io/platforms/javascript/guides/nextjs/sourcemaps/troubleshooting_js.md).

## [Additional Resources](https://docs.sentry.io/platforms/javascript/guides/nextjs/sourcemaps.md#additional-resources)

* [Using sentry-cli to Upload Source Maps](https://docs.sentry.io/cli/releases.md#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)
