Source Maps
Upload your source maps to Sentry to enable readable stack traces in your errors.
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:
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:
.envSENTRY_AUTH_TOKEN=___ORG_AUTH_TOKEN___
and configure sentryTanstackStart in your vite.config.ts:
vite.config.tsimport { 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.
The plugin, by default, automatically enables hidden source maps and deletes .map files after upload.
Configure source map behavior using the plugin options, for example:
vite.config.tsimport { 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 to delete source maps after upload.
If you're experiencing issues with source maps, see Troubleshooting Source Maps.
Our documentation is open source and available on GitHub. Your contributions are welcome, whether fixing a typo (drat!) or suggesting an update ("yeah, this would be better").