feat(tanstackstart-react): Add server-side route parametrization#21147
feat(tanstackstart-react): Add server-side route parametrization#21147nicohrubec wants to merge 6 commits into
Conversation
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>
There was a problem hiding this comment.
Cursor Bugbot has reviewed your changes and found 2 potential issues.
❌ 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; |
There was a problem hiding this comment.
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)
Reviewed by Cursor Bugbot for commit 05d23c8. Configure here.
|
|
||
| function escapeRegex(str: string): string { | ||
| return str.replace(/[.*+?^${}()|[\]\\]/g, '\\$&'); | ||
| } |
There was a problem hiding this comment.
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.
Reviewed by Cursor Bugbot for commit 05d23c8. Configure here.


Server transactions now use parametrized route names instead of raw URLs.
GET /users/123becomesGET /users/$id, fixing high-cardinality transaction grouping. Route patterns are extracted fromrouteTree.gen.tsat build time and matched against request URLs at runtime inwrapFetchWithSentry.