Skip to content

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

Draft
nicohrubec wants to merge 6 commits into
developfrom
feat/tanstack-start-route-parametrization
Draft

feat(tanstackstart-react): Add server-side route parametrization#21147
nicohrubec wants to merge 6 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. Route patterns are extracted from routeTree.gen.ts at build time and matched against request URLs at runtime in wrapFetchWithSentry.

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>
Comment thread packages/tanstackstart-react/src/vite/routePatterns.ts
nicohrubec and others added 2 commits May 23, 2026 23:57
… 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>
Comment thread packages/tanstackstart-react/src/server/routeParametrization.ts
nicohrubec and others added 3 commits May 24, 2026 00:16
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>
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 2 potential issues.

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 05d23c8. Configure here.

}
const aDynamic = aSegments.filter(s => s.startsWith('$')).length;
const bDynamic = bSegments.filter(s => s.startsWith('$')).length;
return aDynamic - bDynamic;
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Splat routes not deprioritized vs named parameter routes

Low Severity

The sort comparator counts both splat segments ($) and named parameter segments ($param) equally via s.startsWith('$'), but splat maps to .+ (matches across /) while named params map to [^/]+ (single segment only). When both /files/$ and /files/$name exist with equal segment count and dynamic count, sort order depends on input order. If the splat appears first, a URL like /files/hello incorrectly matches the less-specific splat pattern instead of the named parameter pattern.

Additional Locations (1)
Fix in Cursor Fix in Web

Reviewed by Cursor Bugbot for commit 05d23c8. Configure here.


function escapeRegex(str: string): string {
return str.replace(/[.*+?^${}()|[\]\\]/g, '\\$&');
}
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Duplicated regex escape utility already exists in core

Low Severity

The local escapeRegex function duplicates escapeStringForRegex already exported from @sentry/core (which is already imported on line 2 of this file). Using the existing utility avoids maintaining two copies and ensures consistent escaping behavior across the codebase.

Fix in Cursor Fix in Web

Reviewed by Cursor Bugbot for commit 05d23c8. Configure here.

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.

1 participant