0
Fork 0
mirror of https://github.com/TanStack/router.git synced 2026-11-16 19:38:07 +00:00
Commit graph

141 commits

Author SHA1 Message Date
Birk Skyum
5ff4f0b8dc
chore: bump esbuild to 0.27.4 (#6975) 2026-03-18 18:09:49 +01:00
Birk Skyum
aaf764bcee
docs: @tailwindcss/vite to 4.2.2 in examples (#6974) 2026-03-18 17:40:04 +01:00
Birk Skyum
3b8ab0fa6b
docs: add devcontainer.json to all e2e/examples (#6972) 2026-03-18 15:43:14 +01:00
Birk Skyum
7d936c6c36
docs: update examples/e2e to vite 8 (#6958) 2026-03-17 20:37:11 +01:00
SeanCassiere
773c7c9cb9
chore: generate route-tree for all sandboxes
a recent change to generator, meant that all the sandboxes had their route-trees files being out-of-date
2026-03-14 23:28:51 +13:00
Manuel Schiller
b7def82c7d
fix: ensure lazy error component is preloaded (#6875) 2026-03-09 23:04:09 +01:00
Manuel Schiller
227dfaf21b
fix: prevent var name clash in generated route for escaped strings (#6680) 2026-02-16 19:10:54 +01:00
Manuel Schiller
523972e0df
fix: shared virtual module for code-split routes (#6659)
* fix: shared virtual module for code-split routes

When a route file has module-level bindings (variables, functions, classes) referenced by **both** split and non-split route properties, the bindings are duplicated — initialized independently in the reference file and in each virtual split file. This breaks singletons, causes double side effects, and wastes bundle size.

```tsx
const collection = { name: 'todos', preload: async () => {} }
export const Route = createFileRoute('/todos')({
  loader: async () => {
    await collection.preload()
  }, // stays in reference
  component: () => <div>{collection.name}</div>, // split to virtual
})
```
In this example, `collection` is initialized in **both** the reference file (because `loader` references it) and the `?tsr-split=component` virtual file (because the component references it). Two separate instances exist at runtime.

To solve this issue, this PR introduces a third virtual module `route.tsx?tsr-shared=1` that contains shared bindings. Both the reference and virtual files import from it.

When `sharedBindings` is empty (the common case — component-only helpers, loader-only code), no shared module exists and the system works exactly as today.

The reference transform runs first and will emit a static import of `?tsr-shared=1` **only when needed**. Since split chunks are only discovered via the reference file's emitted `import('...?tsr-split=...')`, the bundler will always process/evaluate the reference module first. Result: the shared module is evaluated once and then reused by any later-loaded split chunk.
2026-02-14 13:10:54 +01:00
Lee Jong Kyung
5c923e45c3
fix(router): ensure useParams returns parsed params when strict is false (#6387)
* fix: optimize match retrieval by using a Map for previous matches

* feat: add strict false parameter handling and related routes

* replace params only when routeParams is fully parsed

---------

Co-authored-by: Nico Lynzaad <nlynzaad@zylangroup.com>
Co-authored-by: Nico Lynzaad <44094871+nlynzaad@users.noreply.github.com>
2026-02-09 02:44:30 +02:00
Philippe Serhal
6ff1190bdc
chore: add source() to Tailwind v4 imports to ensure consistent hashing (#6459)
Co-authored-by: Claude Opus 4.5 <noreply@anthropic.com>
2026-01-24 01:49:12 +01:00
Flo
f054c0c921
fix: revert "refactor: don't reparse upon navigation (#6398)" (#6468)
Revert "refactor: don't reparse upon navigation (#6398)"

This reverts commit 6cbd96e357.
2026-01-23 16:50:10 +01:00
Manuel Schiller
6cbd96e357
refactor: don't reparse upon navigation (#6398) 2026-01-19 23:00:21 +01:00
Manuel Schiller
2d9193c25c
chore: bump deps (#6408)
Co-authored-by: Brenley Dueck <brenleydueck@gmail.com>
2026-01-18 02:14:48 +01:00
Manuel Schiller
b42f84a4f6
fix: fullpath handling (#6404)
* fix: fullpath handling

fixes #6403
fixes #2675
fixes #4892

* add type test

* preserve / for index routes

* fix  #3005

* fix tests
2026-01-17 17:21:10 +01:00
Manuel Schiller
5299f0be9f
feat: add Route.redirect and getRouteApi.redirect (#6373) 2026-01-14 21:50:58 +01:00
Jakob Norlin
a1324bb155
fix: navigate() with href containing basepath (#6335)
Co-authored-by: Manuel Schiller <manuel.schiller@caligano.de>
2026-01-08 23:33:41 +01:00
Manuel Schiller
04e6d7b064
fix: open redirect (#6309) 2026-01-05 20:07:19 +01:00
Lee Jong Kyung
7ee7069844
Fix(scroll-restoration): handle sessionStorage quota exceeded error in scroll restoration (#6287)
* fix: handle sessionStorage quota exceeded error in scroll restoration

* feat: add scroll error route and tests for sessionStorage handling

---------

Co-authored-by: Nico Lynzaad <44094871+nlynzaad@users.noreply.github.com>
2026-01-05 18:35:06 +02:00
Nico Lynzaad
6ea81b47f7
fix(router-core): make navigate publicHref Aware (#6205)
* update navigate to use publicHref when reload document

* resolve codeRabbit nitpick

* mark publicHref prop as internal
2025-12-24 01:41:22 +02:00
Manuel Schiller
17c07d9369
fix: rewrite causes infinite redirects (#6201) 2025-12-23 12:37:09 +01:00
Birk Skyum
6839bfb1a0
docs: move to tailwind 4 w/ vite (#6168) 2025-12-21 04:13:49 +01:00
Manuel Schiller
c9a19a2e60
feat(router-generator): allow escaping any special string in file-based routing (#6156)
* feat(router-generator): allow escaping any special string in file-based routing

This change extends the router-generator's escaping mechanism to allow ANY
special string to be escaped using square bracket syntax, not just dots.

## Problem

Previously, the router-generator only supported escaping dots using [.]
syntax (e.g., script[.]js.tsx -> /script.js). However, special strings
like 'index', 'route', 'lazy', and underscores ('_') could not be escaped,
making it impossible to create routes with literal paths like /index,
/route, /lazy, or paths containing literal underscores.

## Solution

Extended the escaping mechanism to support:

1. **Escaped special suffixes**: [index], [route], [lazy], [component], etc.
   - [index].tsx -> /index (literal path, NOT treated as index route)
   - [route].tsx -> /route (literal path, NOT treated as layout config)
   - [lazy].tsx -> /lazy (literal path, NOT treated as lazy-loaded route)

2. **Escaped underscores in any position**:
   - Leading: [_]layout.tsx -> /_layout (literal, NOT pathless layout)
   - Trailing: blog[_].tsx -> /blog_ (literal, NOT escaping parent layout)
   - Middle: foo[_]bar.tsx -> /foo_bar (literal underscore preserved)
   - Multiple: api[_]v2[_]users.tsx -> /api_v2_users
   - Fully escaped: [_prefix_middle_suffix].tsx -> /_prefix_middle_suffix

3. **Custom token escaping**: Works with custom indexToken and routeToken
   - [_1nd3x].tsx with indexToken='_1nd3x' -> /_1nd3x (literal path)
   - posts.[_r0ut3_].tsx with routeToken='_r0ut3_' -> /posts/_r0ut3_

## Implementation Details

### src/utils.ts
- Removed '_' from DISALLOWED_ESCAPE_CHARS to allow underscore escaping
- Added isSegmentEscaped() to check if a segment was bracket-escaped
- Added hasEscapedLeadingUnderscore() to detect [_] prefix or [_...] patterns
- Added hasEscapedTrailingUnderscore() to detect [_] suffix or [..._] patterns
- Added removeUnderscoresWithEscape() to preserve escaped underscores
- Added removeLayoutSegmentsWithEscape() to preserve escaped layout segments
- Added isSegmentPathless() to check for non-escaped leading underscores
- Updated inferFullPath() to use escape-aware functions

### src/filesystem/physical/getRouteNodes.ts
- Added escape checking for special suffixes (route, lazy, component, etc.)
- Updated isValidPathlessLayoutRoute() to check for escaped underscores
- Updated getRouteMeta() to accept originalRoutePath and check escaping

### src/generator.ts
- Updated handleNode() to use escape-aware path processing functions
- Compute trimmedOriginalPath alongside trimmedPath for escape detection

## Tests Added

- escaped-special-strings: Tests escaping of index, route, lazy, and
  underscores in various positions (leading, trailing, middle, multiple)
- escaped-custom-tokens: Tests escaping with custom indexToken and
  routeToken configurations

* simplify

* fix test

* add utils unit tests

* add e2e test

* ci: apply automated fixes

---------

Co-authored-by: autofix-ci[bot] <114827586+autofix-ci[bot]@users.noreply.github.com>
2025-12-20 14:51:09 +01:00
Nico Lynzaad
27d1c5ef04
refactor(router-generator): remove experimental nonnested paths (#6154)
* remove experimental non-nested from tests

* remove experimental non-nested from router-generator

* add underscore to list of disallowed escaped characters

* update docs

* fix tests
2025-12-20 14:24:43 +02:00
Birk Skyum
05408f83b4
test(vue-router): sentry integration with tanstackRouterBrowserTracingIntegration (#6139)
vue-router  tanstackRouterBrowserTracingIntegration sentry
2025-12-18 14:15:14 +01:00
Manuel Schiller
16a359bfb6
fix: don't create virtual routes for pathless layouts (#6120) 2025-12-17 03:17:59 +01:00
Lachlan Collins
43fd1328c5
fix: full npm registry URLs, sync package versions (#6035)
* Update repository URLs

* Start sherif fixes

* Fic CI
2025-12-07 11:37:18 +11:00
Hakan Shehu
24ff8955ab
fix(router-core): correctly resolve custom params from declarative masks when building the masked url (#5756)
* Use params from declarative masks

* Add tests for masks

* Include the necessary changes

* Update mask tests

* Add e2e tests

* minor nitpicks

---------

Co-authored-by: Nico Lynzaad <nlynzaad@zylangroup.com>
2025-12-02 18:31:16 +02:00
Shreyas Sarkar
8f5d93b58c
fix: Links always scroll to URL hash on hover (#5930) (#5944) 2025-11-23 01:05:34 +01:00
Birk Skyum
6f06558afa
chore: use "preview" instead of "serve" to refer to "vite preview" (#5917) 2025-11-20 05:08:43 +01:00
Birk Skyum
f830dffb74
test(router): remove flaky query transition test (#5883) 2025-11-16 19:27:33 +01:00
Birk Skyum
559856b7bf
test(router): add view-transition e2e suites (#5869)
* test(router): add view-transition e2e suites

* ci: apply automated fixes

* setup suites

---------

Co-authored-by: autofix-ci[bot] <114827586+autofix-ci[bot]@users.noreply.github.com>
2025-11-14 23:10:31 +01:00
Flo
043e57656d
refactor(router-core): simplify matchId (#5807)
* refactor(router-core): simplify matchId

* ci: apply automated fixes

* update tests

* matchId !== routeId

* nitpicks

* missed in solid router Match

---------

Co-authored-by: autofix-ci[bot] <114827586+autofix-ci[bot]@users.noreply.github.com>
Co-authored-by: Nico Lynzaad <nlynzaad@zylangroup.com>
2025-11-11 00:55:46 +01:00
Birk Skyum
1b75808f37
test(router, start): query navigation transitions (#5802)
* test(router): test query transitions

* ci: apply automated fixes

* test start

* ci: apply automated fixes

* dim double click test

---------

Co-authored-by: autofix-ci[bot] <114827586+autofix-ci[bot]@users.noreply.github.com>
2025-11-10 00:17:53 +01:00
Birk Skyum
fcf1a82412
test: restructure transition e2e tests (#5800) 2025-11-09 19:26:55 +01:00
Nico Lynzaad
23d8ed7715
fix(router-generator): handle deep multi-level non-nested paths with experimental non-nested paths (#5779)
* fix generation of deep non-nested paths

* add router-generator unit tests

* add react-router e2e tests

* add solid-router e2e tests

* resolve typo in heading
2025-11-07 01:53:50 +02:00
Nico Lynzaad
26f23faf13
refactor(router-core): consistent Unicode handling (#5736)
* add router-core fixes and update tests

* update react-router unit tests

* update react-router e2e tests

* update solid-router unit tests

* update solid-router e2e tests

* update test description

* rename function

* rename test as per codeRabbit nitpick

* test cleanup
2025-11-06 03:35:59 +02:00
Birk Skyum
76c4f614f2
fix(solid-router): implement navigation transitions (#5691) 2025-11-04 03:51:16 +01:00
Birk Skyum
1ec38819b6
test(router): make the remount test more thorough (#5684)
test(router): make the remount test more clear if there's extra mount initially
2025-10-29 04:13:54 +01:00
Nico Lynzaad
915de641cd
refactor(router-core): more stable url decoding (#5663)
* add decode path segment util

* ensure navigation and browsing to path has same encoding/decoding

* add e2e tests

* add test recommendations

* nitpick

* minor enhancements

* build array once

* add additional unit and e2e tests

* remove react import from solid test

* nitpicks

* final nitpicks

* use history.push
2025-10-28 23:33:50 +02:00
Birk Skyum
645de2353a
chore: update query to consistent 5.90 (#5634)
* chore: update query to consistent 5.90

* update to 5.90.0

* save bump

* bump root

* use 5.90

* update query integration for solid

* update query integration for solid

* ci: apply automated fixes

* align solid-query versions

* data-only

* lockfile

* lcokfile

---------

Co-authored-by: autofix-ci[bot] <114827586+autofix-ci[bot]@users.noreply.github.com>
2025-10-26 19:29:46 +01:00
Durgé Seerden
9607ef6d16
fix: fix React router Link component in SVG elements (#5590)
* Use getAttribute to access the element target

* Add e2e test for react-router Link in SVG
2025-10-26 17:45:55 +01:00
Birk Skyum
a068c4318e
test(solid-router): add sentry e2e (#5612) 2025-10-25 17:57:12 +02:00
Nico Lynzaad
d293e1b15a
fix(route-core, router-generator): resolve non-nested routes correctly in generator (#5402)
* revert router-core changes

* add experimental nonnested path changes to generator

* update router-generator unit tests

* update basic-file-based-e2e

* cleanup

* cleanup

* add tests for isValidNonNestedPaths

* resolve eslint issues

* align naming to documentation

* cleanup

* update solidjs basic-file-based tests

* update documentation

* ci: apply automated fixes

* resolve test issues

* code rabbit suggestions

* ci: apply automated fixes

* fix excess period in routeTree path

* restore snapshot again

* ci: apply automated fixes

* resolve nitpick

* resolve removeTrailingUnderscore issue

* fix routeTree path

* final nitpicks

* better test description

* exclude snapshots from prettier

* minor cleanup

* resolve change in snapshots due to changes from main

* update prettierignore

---------

Co-authored-by: autofix-ci[bot] <114827586+autofix-ci[bot]@users.noreply.github.com>
2025-10-24 10:29:24 +02:00
Birk Skyum
eab8a9941c
chore: bump tailwind from v3 to v4 with postcss (#5580) 2025-10-22 03:42:26 +02:00
Nico Lynzaad
afaecfc3e5
fix(router-generator): remove trailing slash from pathless route group paths (#5491) 2025-10-16 20:25:48 +02:00
Manuel Schiller
2db746c4fc
fix: navigate() respects rewrites when reloadDocument=true (#5389) 2025-10-06 23:18:59 +02:00
Nico Lynzaad
4b0004cfbb
test(e2e-Utils): export built package from e2eUtils (#5336)
* add build step and update exports

* address flaky test

* export types

* ci: apply automated fixes

* use vite for building

* ci: apply automated fixes

* code rabbit issues

---------

Co-authored-by: autofix-ci[bot] <114827586+autofix-ci[bot]@users.noreply.github.com>
2025-10-02 03:22:34 +02:00
Magnus May
2ff5bc20f7
docs: add Bun production server guide for TanStack Start (#5237)
Co-authored-by: Claude <noreply@anthropic.com>
Co-authored-by: Manuel Schiller <manuel.schiller@caligano.de>
Co-authored-by: autofix-ci[bot] <114827586+autofix-ci[bot]@users.noreply.github.com>
2025-09-27 01:01:49 +02:00
Manuel Schiller
32faee22da
feat: Start RC (#5189)
Co-authored-by: Nico Lynzaad <nlynzaad@zylangroup.com>
Co-authored-by: autofix-ci[bot] <114827586+autofix-ci[bot]@users.noreply.github.com>
Co-authored-by: Tanner Linsley <tannerlinsley@users.noreply.github.com>
Co-authored-by: James Opstad <13586373+jamesopstad@users.noreply.github.com>
Co-authored-by: chorobin <chrishorobin@hotmail.com>
Co-authored-by: Tanner Linsley <tannerlinsley@gmail.com>
Co-authored-by: Nico Lynzaad <44094871+nlynzaad@users.noreply.github.com>
Co-authored-by: coderabbitai[bot] <136622811+coderabbitai[bot]@users.noreply.github.com>
Co-authored-by: hokkyss <hokkyss2@gmail.com>
Co-authored-by: Philippe Serhal <philippe.serhal@gmail.com>
Co-authored-by: Jack Herrington <jherr@pobox.com>
Co-authored-by: Brenley Dueck <brenleydueck@gmail.com>
2025-09-23 11:34:54 -06:00
Nico Lynzaad
ecd79d2b63
fix(router-core): Non nested paths - only strip trailing underscore on route segments (#5182)
as part of #5169 we made changes to strip underscores from the paths to
ensure it is dealt with correctly during parsing.

inadvertently this stripped it from not only the route segments but also
the base segments. This PR resolves that issue by making
`baseParsePathName` aware which type of segments it is parsing.

a new optional boolean paramater, ```basePathValues```, is introduced in
`baseParsePathName` and `parsePathname` to allow this distinction
between routeSegments and/or basesegments to be passed on to
`baseParsePathName`.

2 new functions are introduced `parseBasePathSegments` and
`parseRoutePathSegments`, which is just wrapper functions around
`parsePathname`, but ensures clearer understanding of what set of
parsing instructions is applied and `basePathValues `is set correctly
based on the requirement.

updated the unit tests to take into account the need not to strip the
base values and also enhanced the e2e tests as well to ensure more
through testing with different usages.

<!-- This is an auto-generated comment: release notes by coderabbit.ai
-->
## Summary by CodeRabbit

- New Features
- Added non-nested route demos (named, prefix, suffix, path) with
index/foo/bar pages and updated navigation in React and Solid examples.
- Bug Fixes
- Improved path parsing/matching to handle non-nested segments,
prefixes/suffixes and trailing underscores; refined route
sorting/resolution.
- Tests
- Added comprehensive E2E coverage for non-nested paths; removed
obsolete baz-based tests.
- Expanded unit tests for path interpolation and matching (underscore,
prefix/suffix cases).
<!-- end of auto-generated comment: release notes by coderabbit.ai -->
2025-09-22 03:12:27 +02:00