-
-
Notifications
You must be signed in to change notification settings - Fork 1.7k
docs(tanstackstart-react): Document tunnel route adapter #17504
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
nikolovlazar
merged 4 commits into
master
from
lazarnikolov/js-2144-tanstack-start-tunnel-adapter-docs
Apr 29, 2026
Merged
Changes from all commits
Commits
Show all changes
4 commits
Select commit
Hold shift + click to select a range
a8806c1
docs(tanstackstart-react): Document tunnel route adapter
nikolovlazar a828563
chore(tanstackstart-react): Set AvailableSince version to 10.51.0
nikolovlazar 027e60d
fix(tanstackstart-react): Use consistent code fence language markers
nikolovlazar 0815ed2
fix(tanstackstart-react): Correct line highlight for tunnel option
nikolovlazar File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
58 changes: 58 additions & 0 deletions
58
...orms/javascript/guides/tanstackstart-react/features/createSentryTunnelRoute.mdx
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,58 @@ | ||
| --- | ||
| title: createSentryTunnelRoute | ||
| description: "Learn how to manually define a Sentry tunnel route in your TanStack Start app." | ||
| --- | ||
|
|
||
| <AvailableSince version="10.51.0" /> | ||
|
|
||
| <Alert level="info"> | ||
| If you can use the `sentryTanstackStart` Vite plugin, prefer its | ||
| [`tunnelRoute`](/platforms/javascript/guides/tanstackstart-react/features/sentryTanstackStart/#tunnel-route) | ||
| option. It registers the route for you and automatically wires up the client | ||
| `tunnel` option. Use `createSentryTunnelRoute` only when you need full control over | ||
| the route file, the DSN allowlist, or can't use the Vite plugin. | ||
| </Alert> | ||
|
|
||
| The `createSentryTunnelRoute` helper returns a TanStack Start server-route configuration with a `POST` handler that forwards Sentry envelopes to Sentry's ingest servers. Use it inside a file route to expose a same-origin tunnel endpoint. | ||
|
|
||
| ## Usage | ||
|
|
||
| Create a server route at the path you want to tunnel through, and pass the list of DSNs you want to allow: | ||
|
|
||
| ```typescript {filename:src/routes/monitor.ts} | ||
| import { createFileRoute } from "@tanstack/react-router"; | ||
| import * as Sentry from "@sentry/tanstackstart-react"; | ||
|
|
||
| export const Route = createFileRoute("/monitor")({ | ||
| server: Sentry.createSentryTunnelRoute({ | ||
| allowedDsns: ["___PUBLIC_DSN___"], | ||
| }), | ||
| }); | ||
| ``` | ||
|
|
||
| Then, set the matching `tunnel` option in your client `Sentry.init()` so the browser SDK sends events to your route instead of directly to Sentry: | ||
|
|
||
| ```tsx {filename:src/router.tsx} {4} | ||
| Sentry.init({ | ||
| dsn: "___PUBLIC_DSN___", | ||
| // ... | ||
| tunnel: "/monitor", | ||
| }); | ||
| ``` | ||
|
|
||
| ## Options | ||
|
|
||
| ### `allowedDsns` | ||
|
|
||
| A list of DSN strings that the route is allowed to forward to. The route validates each incoming envelope against this list and rejects any DSN that isn't allowed. | ||
|
|
||
| If `allowedDsns` is omitted or empty, the route falls back to the DSN of the active server-side Sentry SDK at runtime. If neither is available, requests to the route return a 500 response. | ||
|
|
||
| ```typescript {filename:src/routes/monitor.ts} | ||
| Sentry.createSentryTunnelRoute({ | ||
| allowedDsns: [ | ||
| "https://public@o0.ingest.sentry.io/1", | ||
| "https://public@o0.ingest.sentry.io/2", | ||
| ], | ||
| }); | ||
| ``` |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
not a huge fan of back to back Alerts being rendered, is there a better place for this? Not a blocker tho