Skip to content

feat(tanstackstart-react): Add server-side route parametrization#21147

Merged
nicohrubec merged 20 commits into
developfrom
feat/tanstack-start-route-parametrization
May 26, 2026
Merged

feat(tanstackstart-react): Add server-side route parametrization#21147
nicohrubec merged 20 commits into
developfrom
feat/tanstack-start-route-parametrization

Conversation

@nicohrubec
Copy link
Copy Markdown
Member

@nicohrubec nicohrubec commented May 23, 2026

Server transactions now use parametrized route names instead of raw URLs. GET /users/123 becomes GET /users/$id, fixing high-cardinality transaction grouping.

The framework provides no way to do this natively, so this is implemented using a build manifest approach that should hopefully work in most cases. Route patterns are extracted from routeTree.gen.ts at build time and presorted by number of static/dynamic segments, then matched against request URLs at runtime in wrapFetchWithSentry.

Closes #18284

Comment thread packages/tanstackstart-react/src/vite/routePatterns.ts
Comment thread packages/tanstackstart-react/src/server/routeParametrization.ts
Comment thread packages/tanstackstart-react/src/server/routeParametrization.ts Outdated
Comment thread packages/tanstackstart-react/src/server/routeParametrization.ts Outdated
Comment thread packages/tanstackstart-react/src/server/routeParametrization.ts
@nicohrubec nicohrubec marked this pull request as ready for review May 26, 2026 11:28
@nicohrubec nicohrubec requested a review from a team as a code owner May 26, 2026 11:28
@nicohrubec nicohrubec requested review from mydea and s1gr1d and removed request for a team May 26, 2026 11:28
Comment thread packages/tanstackstart-react/src/vite/routePatterns.ts Outdated
Comment thread packages/tanstackstart-react/src/server/wrapFetchWithSentry.ts
Comment thread packages/tanstackstart-react/src/server/routeParametrization.ts
Copy link
Copy Markdown

@cursor cursor Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Cursor Bugbot has reviewed your changes and found 1 potential issue.

Fix All in Cursor

❌ Bugbot Autofix is OFF. To automatically fix reported issues with cloud agents, enable autofix in the Cursor dashboard.

Reviewed by Cursor Bugbot for commit 59c5638. Configure here.

Comment thread packages/tanstackstart-react/src/vite/routePatterns.ts
Comment thread packages/tanstackstart-react/src/server/routeParametrization.ts
nicohrubec and others added 15 commits May 26, 2026 16:36
Extracts route patterns from routeTree.gen.ts at build time and matches URLs at runtime to parametrize server transaction names (e.g., `GET /users/123` becomes `GET /users/$id`).

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
… properties

Nested routes have relative `path:` values (e.g., `/$userId`) but the
`fullPaths` type union has the resolved full paths (e.g., `/users/$userId`).
Also handles multi-line union format.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Verifies that /users/123 is correctly parametrized to GET /users/$userId,
covering the nested route case where path: values are relative.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
A bare `$` segment matches multiple path segments (e.g., `/files/$`
matches `/files/a/b/c`).

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
The pattern list is static at build time. Sort once and compile regexes
once instead of on every request.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
… sort

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
- Assert transaction_info.source is 'route' on all tests
- Assert client-side parametrization on page and nested routes
- Add API route parametrization test
- Remove redundant static route unit test

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
…vailable

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Sorting now happens once in extractRoutePatterns instead of on every
request. Also adds getCurrentScope().setTransactionName() so errors
captured during a request get the parametrized name.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
nicohrubec and others added 5 commits May 26, 2026 16:36
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
TanStack Router's generator has a quoteStyle config that can be set to
"double". The regex now matches both single and double quotes.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
@nicohrubec nicohrubec force-pushed the feat/tanstack-start-route-parametrization branch from 1932bb8 to a6f5a11 Compare May 26, 2026 14:37
@nicohrubec nicohrubec merged commit 515f551 into develop May 26, 2026
46 checks passed
@nicohrubec nicohrubec deleted the feat/tanstack-start-route-parametrization branch May 26, 2026 14:49
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Server routing tracing

2 participants