---
title: "createSentryTunnelRoute"
description: "Learn how to manually define a Sentry tunnel route in your TanStack Start app."
url: https://docs.sentry.io/platforms/javascript/guides/tanstackstart-react/features/createSentryTunnelRoute/
---

# createSentryTunnelRoute for TanStack Start React

Available since: `v10.51.0`

For most apps, set up the tunnel as described in [Tunneling](https://docs.sentry.io/platforms/javascript/guides/tanstackstart-react/configuration/tunneling.md), which needs no route file. Use `createSentryTunnelRoute` only when you want the tunnel as a route in your app.

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](https://docs.sentry.io/platforms/javascript/guides/tanstackstart-react/features/createSentryTunnelRoute.md#usage)

Create a server route at the path you want to tunnel through, and pass the list of DSNs you want to allow:

```typescript
import { createFileRoute } from "@tanstack/react-router";
import * as Sentry from "@sentry/tanstackstart-react";

export const Route = createFileRoute("/monitor")({
  server: Sentry.createSentryTunnelRoute({
    allowedDsns: ["https://<key>@o<orgId>.ingest.sentry.io/<projectId>"],
  }),
});
```

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
Sentry.init({
  dsn: "https://<key>@o<orgId>.ingest.sentry.io/<projectId>",
  // ...
  tunnel: "/monitor",
});
```

## [Options](https://docs.sentry.io/platforms/javascript/guides/tanstackstart-react/features/createSentryTunnelRoute.md#options)

### [`allowedDsns`](https://docs.sentry.io/platforms/javascript/guides/tanstackstart-react/features/createSentryTunnelRoute.md#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.

The DSN of the active server-side Sentry SDK is always allowed too. If `allowedDsns` is omitted or empty, the route uses only that DSN. If neither is available, requests to the route return a 500 response.

```typescript
Sentry.createSentryTunnelRoute({
  allowedDsns: [
    "https://public@o0.ingest.sentry.io/1",
    "https://public@o0.ingest.sentry.io/2",
  ],
});
```
