---
title: "Source Maps"
description: "Upload your source maps to Sentry to enable readable stack traces in your errors."
url: https://docs.sentry.io/platforms/javascript/guides/tanstackstart-react/sourcemaps/
---

# Source Maps | Sentry for TanStack Start React

Use the `sentryTanstackStart` Vite plugin to automatically upload source maps during production builds.

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

## [Uploading Source Maps in a TanStack Start Project Using sentryTanstackStart](https://docs.sentry.io/platforms/javascript/guides/tanstackstart-react/sourcemaps.md#uploading-source-maps-in-a-tanstack-start-project-using-sentrytanstackstart)

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

Using environment variables in Vite configs

Vite doesn't automatically load `.env` files into `process.env` when evaluating the config file. If you store your auth token in a `.env` file and want to access it via `process.env.SENTRY_AUTH_TOKEN`, use Vite's [`loadEnv`](https://vite.dev/guide/api-javascript#loadenv) helper:

`vite.config.js`

```javascript
import { defineConfig, loadEnv } from "vite";

export default defineConfig(({ mode }) => {
  const env = loadEnv(mode, process.cwd(), "");

  return {
    plugins: [
      sentryVitePlugin({
        authToken: env.SENTRY_AUTH_TOKEN,
        // ...
      }),
    ],
  };
});
```

Alternatively, use a `.env.sentry-build-plugin` file, which the Sentry plugin reads automatically.

Configure `sentryTanstackStart` in your `vite.config.ts`:

`vite.config.ts`

```typescript
import { defineConfig } from "vite";
import { sentryTanstackStart } from "@sentry/tanstackstart-react/vite";
import { tanstackStart } from "@tanstack/react-start/plugin/vite";

export default defineConfig({
  plugins: [
    tanstackStart(),
    // other plugins - sentryTanstackStart should be last
    sentryTanstackStart({
      org: "___ORG_SLUG___",
      project: "___PROJECT_SLUG___",
      authToken: process.env.SENTRY_AUTH_TOKEN,
    }),
  ],
});
```

Source map upload **only** works when `org`, `project`, and `authToken` are all configured. Without these options, source maps will not be uploaded to Sentry.

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

The plugin, by default, automatically enables hidden source maps and deletes `.map` files after upload.

Configure source map behavior using the [plugin options](https://docs.sentry.io/platforms/javascript/sourcemaps/uploading/vite.md), for example:

`vite.config.ts`

```typescript
import { defineConfig } from "vite";
import { sentryTanstackStart } from "@sentry/tanstackstart-react/vite";
import { tanstackStart } from "@tanstack/react-start/plugin/vite";

export default defineConfig({
  plugins: [
    tanstackStart(),
    sentryTanstackStart({
      org: "___ORG_SLUG___",
      project: "___PROJECT_SLUG___",
      authToken: process.env.SENTRY_AUTH_TOKEN,

      sourcemaps: {
        assets: ["./dist/**/*"],
        ignore: ["**/node_modules/**"],
        filesToDeleteAfterUpload: [
          "./**/*.map",
          ".*/**/public/**/*.map",
          "./dist/**/client/**/*.map",
        ],
      },
    }),
  ],
});
```

Generating source maps **may expose them to the public**, potentially causing your source code to be leaked. The `sentryTanstackStart` plugin automatically deletes source map files after upload by default. If you customize this behavior, ensure your server denies access to `.js.map` files, or configure [`sourcemaps.filesToDeleteAfterUpload`](https://docs.sentry.io/platforms/javascript/sourcemaps/uploading/vite.md) to delete source maps after upload.

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

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

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

## Pages in this section

- [Uploading Source Maps](https://docs.sentry.io/platforms/javascript/guides/tanstackstart-react/sourcemaps/uploading.md)
- [Troubleshooting Source Maps](https://docs.sentry.io/platforms/javascript/guides/tanstackstart-react/sourcemaps/troubleshooting_js.md)
