sentryTanstackStart
Learn about the sentryTanstackStart Vite plugin.
Available since: v10.35.0
The sentryTanstackStart Vite plugin simplifies source map configuration for TanStack Start applications. It automatically handles source map generation and upload to Sentry during production builds.
To automatically upload source maps, you need to provide your Sentry auth token, organization, and project slugs in your Vite configuration. The plugin then, by default, automatically enables hidden source maps and deletes .map files after upload.
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___
SENTRY_AUTH_TOKEN=___ORG_AUTH_TOKEN___
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,
}),
],
});
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.
The plugin passes through all options to the underlying @sentry/vite-plugin. See the Sentry Vite Plugin documentation for the full list of available options.
Available since: v10.37.0
The plugin automatically instruments all TanStack Start middlewares for tracing by default. To disable this behavior:
vite.config.tssentryTanstackStart({
// ...
autoInstrumentMiddleware: false,
}),
sentryTanstackStart({
// ...
autoInstrumentMiddleware: false,
}),
Available since: v10.55.0
The reactComponentAnnotation option annotates your React components with data-sentry-component and data-sentry-source-file attributes at build time. This lets you see component names instead of generic selectors in Session Replay, breadcrumbs, and performance monitoring.
vite.config.tssentryTanstackStart({
// ...
reactComponentAnnotation: {
enabled: true,
},
}),
sentryTanstackStart({
// ...
reactComponentAnnotation: {
enabled: true,
},
}),
To exclude specific components from annotation:
vite.config.tssentryTanstackStart({
// ...
reactComponentAnnotation: {
enabled: true,
ignoredComponents: ["MyInternalComponent"],
},
}),
sentryTanstackStart({
// ...
reactComponentAnnotation: {
enabled: true,
ignoredComponents: ["MyInternalComponent"],
},
}),
Available since: v10.51.0
The tunnelRoute option registers a same-origin TanStack Start server route that forwards Sentry envelopes to Sentry's ingest servers. It also automatically sets the client tunnel option in Sentry.init() so browser events go through that route. This helps avoid ad blockers and corporate firewalls that block requests to *.sentry.io.
tunnelRoute accepts three shapes:
Generates an opaque, unguessable route path for each dev session and production build. Because the path changes between builds, ad blockers can't reliably target it.
vite.config.tssentryTanstackStart({
tunnelRoute: true,
}),
sentryTanstackStart({
tunnelRoute: true,
}),
Pass a string to use a fixed route path. This is easier to reason about, but a known path is easier for ad blockers to add to a list.
vite.config.tssentryTanstackStart({
tunnelRoute: "/monitor",
}),
sentryTanstackStart({
tunnelRoute: "/monitor",
}),
Use the object form to control the DSN allowlist or set a static path explicitly:
vite.config.tssentryTanstackStart({
tunnelRoute: {
allowedDsns: ["___PUBLIC_DSN___"],
path: "/monitor",
},
}),
sentryTanstackStart({
tunnelRoute: {
allowedDsns: ["___PUBLIC_DSN___"],
path: "/monitor",
},
}),
allowedDsns— only envelopes targeting one of these DSNs are forwarded. If omitted or empty, the route falls back to the DSN of the active server-side Sentry SDK at runtime.path— the public route path. If omitted, an opaque path is generated (same behavior astunnelRoute: true).
Setting `tunnel` in `Sentry.init()` overrides this option
If you also pass tunnel to Sentry.init(), the runtime option wins and the managed tunnel route is bypassed. The SDK logs a warning when this happens.
Opaque paths are not stable
When using tunnelRoute: true (or the object form without path), the generated path changes for each dev session and each production build. Don't hard-code it elsewhere in your app or infrastructure.
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").