---
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/remix/sourcemaps/
---

# Source Maps | Sentry for Remix

To enable readable stack traces in your Sentry errors, you need to upload your source maps to [Sentry](https://sentry.io/welcome/).

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

See how uploading source maps lets you see the exact line of code that caused an error:

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

If you installed the Remix SDK with the [Sentry Wizard](https://docs.sentry.io/platforms/javascript/guides/remix.md#install), source maps upload was **already configured for you**. Whenever you run the `build` script in your `package.json` source maps will be uploaded automatically.

If you installed the SDK manually or the wizard failed, follow the steps below to manually configure source maps upload.

### [Using Vite Plugin (Recommended)](https://docs.sentry.io/platforms/javascript/guides/remix/sourcemaps.md#using-vite-plugin-recommended)

Starting from version 2.2.0, Remix supports [Vite](https://vitejs.dev/) as a build tool, and from Remix version 2.7.0 it's stable and the recommended way to build your application.

If you use Vite to build your project, you can use the [Vite plugin](https://docs.sentry.io/platforms/javascript/sourcemaps/uploading/vite.md) to upload source maps to Sentry.

First, install the plugin if you haven't already done so:

```bash
npm install @sentry/vite-plugin --save-dev
```

Then, add the plugin to your Vite configuration:

`vite.config.ts`

```typescript
import { defineConfig } from "vite";
import { vitePlugin as remix } from "@remix-run/dev";
import { sentryVitePlugin } from "@sentry/vite-plugin";

export default defineConfig({
  plugins: [
    remix({
      // ... your Remix plugin options
    }),
    sentryVitePlugin({
      // If you use .sentryclirc or environment variables,
      // you don't need to specify these options
      authToken: "___SENTRY_AUTH_TOKEN___",
      org: "___SENTRY_ORG_SLUG___",
      project: "___SENTRY_PROJECT_SLUG___",

      sourcemaps: {
        // As you're enabling client source maps, you probably want to delete them after they're uploaded to Sentry.
        // Set the appropriate glob pattern for your output folder - some glob examples below:
        filesToDeleteAfterUpload: [
          "./**/*.map",
          ".*/**/public/**/*.map",
          "./dist/**/client/**/*.map",
        ],
      },
    }),
  ],
  build: {
    sourcemap: "hidden", // Source map generation must be turned on ("hidden", true, etc.)
    // ... rest of your Vite build options
  },

  // ... rest of your Vite config
});
```

Generating source maps **may expose them to the public**, potentially causing your source code to be leaked. You can prevent this by configuring your server to deny access to `.js.map` files, or by using [Sentry Vite Plugin's `sourcemaps.filesToDeleteAfterUpload`](https://www.npmjs.com/package/@sentry/vite-plugin#sourcemapsfilestodeleteafterupload) option to delete source maps after they've been uploaded to Sentry.

To see the full list of options, refer to the [Vite plugin documentation](https://www.npmjs.com/package/@sentry/vite-plugin).

### [Using `sentry-upload-sourcemaps` Script](https://docs.sentry.io/platforms/javascript/guides/remix/sourcemaps.md#using-sentry-upload-sourcemaps-script)

If you're not using Vite to build your project, you can use the `sentry-upload-sourcemaps` script to upload source maps to Sentry.

The Sentry Remix SDK provides a script to automatically create a release and upload source maps after you've built your project. Under the hood, it uses the [Sentry CLI](https://docs.sentry.io/cli.md).

This script requires setting an auth token, which can either be done through a `.sentryclirc` file in the root of your project or through environment variables:

`.sentryclirc`

```ini
# Do not commit this file to your repository!
# Sentry Auth tokens should be treated as a secret.
[auth]
token=___ORG_AUTH_TOKEN___
```

Next, adjust your `package.json`'s production build command to include the `sentry-upload-sourcemaps` script:

`package.json`

```json
{
  "scripts": {
    "build": "remix build --sourcemap && sentry-upload-sourcemaps --org ___ORG_SLUG___ --project ___PROJECT_SLUG___"
  }
}
```

Alternatively, you can run the script directly with `npx`:

```bash
npx sentry-upload-sourcemaps --org ___ORG_SLUG___ --project ___PROJECT_SLUG___

# For usage details run
npx sentry-upload-sourcemaps --help
```

To generate source maps with your Remix project, you need to call `remix build` with the `--sourcemap` option.

Please refer to the [Remix CLI docs](https://remix.run/docs/en/main/other-api/dev#options) for more information.

### [Remove Remix Source Maps](https://docs.sentry.io/platforms/javascript/guides/remix/sourcemaps.md#remove-remix-source-maps)

Remix validly discourages hosting source maps in production. After uploading the maps to Sentry, we suggest you delete the `.map` files. The `sentry-upload-sourcemaps` script will automatically try to delete all generated source maps after they're uploaded (unless the `--deleteAfterUpload` flag is provided).

If you want to be extra sure they're deleted, you can use the following shell script:

```bash
find ./public/build -type f -name '*.map' -delete
find ./build -type f -name '*.map' -delete
```

Please note that these commands might vary for the operating system or shell you use.

By default, if Sentry can't find the uploaded files it needs, it will attempt to download them from the URLs in the stack trace. To disable this, turn off "Enable JavaScript source fetching" in either your organization's "Security & Privacy" settings or your project's general settings.

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

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