# Source Maps | Sentry for Nuxt

`@sentry/nuxt` uses the [Sentry Vite Plugin](https://www.npmjs.com/package/@sentry/vite-plugin) and the [Sentry Rollup Plugin](https://www.npmjs.com/package/@sentry/rollup-plugin) to generate and upload source maps automatically. This means that when you run a production build (`nuxt build`), source maps will be generated and uploaded to Sentry, so that errors in Sentry will contain readable stack traces.

## [Configure Source Maps Upload](https://docs.sentry.io/platforms/javascript/guides/nuxt/sourcemaps.md#configure-source-maps-upload)

To automatically upload source maps, you need to provide your Sentry auth token, your organization, and project slugs to the `sentry` options in your Nuxt config:

`nuxt.config.ts`

```javascript
export default defineNuxtConfig({
  modules: ["@sentry/nuxt/module"],

  sentry: {
    org: "example-org",
    project: "example-project",
    authToken: "sntrys_YOUR_TOKEN_HERE",
  },
});
```

**Note:** Source maps are only generated and uploaded during **production builds** (`nuxt build`). Development builds (`nuxt 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:

### [Enabling Client-side Source Map Generation](https://docs.sentry.io/platforms/javascript/guides/nuxt/sourcemaps.md#enabling-client-side-source-map-generation)

To enable client-side source maps, you need to do so explicitly. Nuxt applies default [source map settings](https://nuxt.com/docs/api/nuxt-config#sourcemap), and the Sentry Nuxt Module respects these when they are defined.

To enable client-side source map generation, add the following to your Nuxt configuration:

`nuxt.config.ts`

```javascript
export default defineNuxtConfig({

  sourcemap: { client: "hidden" },

});
```

The `hidden` option functions the same as `true`, by enabling source map generation. However, it also suppresses the source map reference comments that normally appear at the end of each generated file in the build output. This option keeps the source maps available without exposing their references in the files.

When you open your browser's developer tools, the browser tries to fetch source maps using the reference comments found in bundled files. If the source maps are uploaded to Sentry and removed from the client side, these references cause 404 errors in the developer tools. The `hidden` option stops these comments from being generated, preventing browsers from trying to fetch missing files and avoiding unnecessary errors.

## [Uploading Source Maps in a Nuxt Project](https://docs.sentry.io/platforms/javascript/guides/nuxt/sourcemaps.md#uploading-source-maps-in-a-nuxt-project)

`@sentry/nuxt` will generate and upload source maps automatically during production builds, so that errors in Sentry contain readable stack traces.

### [Automatic Setup](https://docs.sentry.io/platforms/javascript/guides/nuxt/sourcemaps.md#automatic-setup)

The easiest way to configure uploading source maps is by using the [Sentry Wizard](https://docs.sentry.io/platforms/javascript/guides/nuxt.md#step-1-install).

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

```bash
SENTRY_AUTH_TOKEN=sntrys_YOUR_TOKEN_HERE
```

#### [2. Enable Client-side Source Map Generation](https://docs.sentry.io/platforms/javascript/guides/nuxt/sourcemaps.md#2-enable-client-side-source-map-generation)

To enable client-side source maps, you need to do so explicitly. Nuxt applies default [source map settings](https://nuxt.com/docs/api/nuxt-config#sourcemap), and the Sentry Nuxt Module respects these when they are defined.

To enable client-side source map generation, add the following to your Nuxt configuration:

`nuxt.config.ts`

```javascript
export default defineNuxtConfig({
  sourcemap: { client: "hidden" },
});
```

The `hidden` option functions the same as `true`, by enabling source map generation. However, it also suppresses the source map reference comments that normally appear at the end of each generated file in the build output. This option keeps the source maps available without exposing their references in the files.

When you open your browser's developer tools, the browser tries to fetch source maps using the reference comments found in bundled files. If the source maps are uploaded to Sentry and removed from the client side, these references cause 404 errors in the developer tools. The `hidden` option stops these comments from being generated, preventing browsers from trying to fetch missing files and avoiding unnecessary errors.

#### [3. Source Map Options](https://docs.sentry.io/platforms/javascript/guides/nuxt/sourcemaps.md#3-source-map-options)

Configure source map behavior in your Nuxt config:

`nuxt.config.ts`

```javascript
export default defineNuxtConfig({
  modules: ["@sentry/nuxt/module"],
  sentry: {
    org: "example-org",
    project: "example-project",
    authToken: process.env.SENTRY_AUTH_TOKEN,
  },
});
```

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

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

## [Additional Resources](https://docs.sentry.io/platforms/javascript/guides/nuxt/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)
