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

168 commits

Author SHA1 Message Date
Flo
9c1871ccc8
fix: harden URL handling across Router and Start (#8308)
* fix: harden URL handling across Router and Start

* fix: preserve unload blockers after document navigation

* perf: reduce document navigation guard size
2026-09-09 23:03:49 +02:00
Flo
0654c0a1a4
fix(router-core): reload documents for cross-origin rewrites (#8287)
* fix(router-core): reload documents for cross-origin rewrites

* test(router): expand document navigation coverage

* fix(router): respect registered document navigation blockers
2026-09-08 01:23:05 +02:00
Flo
0f40695fbe
test: cover existing navigation and redirect behavior (#8286) 2026-09-07 21:35:15 +02:00
Flo
9035abc411
fix(history): handle blockers consistently across history traversal (#8264)
* fix(history): preserve unload blockers during back and forward navigation

* fix(history): respect ignoreBlocker in go navigation

* fix(history): reverse blocked traversal by its delta
2026-09-06 16:19:47 +02:00
Manuel Schiller
65d565c946
fix route trees (#8197) 2026-08-31 01:34:33 +02:00
Flo
cb281d70c1
fix(router-core): preserve context during reloads (#8130)
* fix(router-core): preserve context during reloads

* ci: apply automated fixes

* test(router): consolidate issue 8115 coverage

* fix(vue-router): react to provider context changes

* fix(router-core): refine context reconstruction

* bytes

* type fixes

* context + immediate UI on load

* coderabbit is happy

* no context in pending/error/notFound components

* changesets

---------

Co-authored-by: autofix-ci[bot] <114827586+autofix-ci[bot]@users.noreply.github.com>
2026-08-20 23:34:06 +02:00
Flo
f97188fdb4
chore: localize package dependencies (#8078) 2026-08-15 13:42:24 +02:00
Flo
31355ae92c
fix(react-router): useMatchRoute w/ React Compiler (#8015)
* fix(react-router): useMatchRoute w/ React Compiler

* test(react-router): add React Compiler E2E

Co-authored-by: Kamal Bennani <kamal.bennani@aircall.io>

* disable eslint react-hooks/exhaustive-deps for known static condition w/ DCE

* test(react-router): cover useMatchRoute callback identity

Co-authored-by: Sarah Gerrard <98355961+LadyBluenotes@users.noreply.github.com>

* test(react-router): rely on useMatchRoute subscription

* test(react-router): exercise compiler-generated memoization

* no useCallback during SSR

* update docs

---------

Co-authored-by: Kamal Bennani <kamal.bennani@aircall.io>
Co-authored-by: Sarah Gerrard <98355961+LadyBluenotes@users.noreply.github.com>
2026-08-12 10:35:50 +02:00
Flo
697ebb6ddb
fix(react-router): prevent blank frame before initial pending UI (#7961)
* fix(react-router): prevent blank initial pending frame

* test(react-router): remove obsolete issue 4759 unit test

* alternative fix

* ci: apply automated fixes

* simplify code comment

---------

Co-authored-by: autofix-ci[bot] <114827586+autofix-ci[bot]@users.noreply.github.com>
2026-08-06 00:09:29 +02:00
Flo
45c4ad8d62
fix(router-core): lane match loader rewrite (#7805)
* fix: lane match loader rewrite

---------

Co-authored-by: Manuel Schiller <6340397+schiller-manuel@users.noreply.github.com>
2026-08-04 20:28:11 +02:00
Cong-Cong Pan
f04ddc61e7
fix(start): skip errored Rspack modules during import protection (#7685)
Co-authored-by: autofix-ci[bot] <114827586+autofix-ci[bot]@users.noreply.github.com>
2026-07-29 21:11:16 +02:00
Manuel Schiller
88f366ab8e
chore: migrate to typescript 7 (#7887) 2026-07-23 23:10:51 +02:00
Manuel Schiller
218eab2c3b
chore: regenerate route trees (#7853) 2026-07-19 09:20:56 +02:00
Pierre-Luc Auclair
a41f26547c
chore(deps): bump @playwright/test to ^1.61.0 across the workspace (#7772) 2026-07-14 00:06:59 +02:00
Collin Dillinger
9809a0619d
fix(router-core): preserve percent-encoded URL-unsafe chars in decodeSegment (#7695)
* fix(router-core): preserve percent-encoded URL-unsafe chars in decodeSegment

Replace sanitizePathSegment (which stripped control characters) with a
re-encode step that keeps WHATWG path percent-encode set characters and
control characters in their encoded form after decodeURI.

This preserves the existing decodeURI-based approach which correctly
handles multi-byte UTF-8 sequences, while fixing the mismatch between
the original request URL and the router's internal representation that
caused infinite 307 redirect loops on paths containing these characters.

Fixes #7587.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>

* ci: apply automated fixes

---------

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Co-authored-by: autofix-ci[bot] <114827586+autofix-ci[bot]@users.noreply.github.com>
Co-authored-by: Flo <me@florianpellet.com>
2026-06-30 23:27:21 +02:00
Elecmonkey
e499164c72
feat(start-plugin-core): support Rsbuild preview SSR middleware (#7372)
* fix(start-plugin-core): support rsbuild preview SSR

* fix(start-plugin-core): always install rsbuild SSR middleware in preview

Preview is the only SSR handler in `rsbuild preview`, so gate the opt-out
to dev only and keep the option named `installDevServerMiddleware`.
2026-06-16 10:30:39 +02:00
Manuel Schiller
9cb7a003e6
feat(rsbuild): add RSC support (#7509)
Co-authored-by: autofix-ci[bot] <114827586+autofix-ci[bot]@users.noreply.github.com>
2026-05-30 15:16:10 +02:00
Manuel Schiller
90adda91aa
fix: bundled dev support for vite (#7482) 2026-05-24 22:08:23 +02:00
Manuel Schiller
51a97a167f
feat(start): support rsbuild iife client output (#7477) 2026-05-24 02:02:05 +02:00
Flo
9f6258f23e
chore: update zod to v4.4.3 (#7441)
* chore: update zod to v4.4.3

* fix(start): preserve route path defaults

* fix(examples): resolve zod 4 build failures
2026-05-20 08:41:45 +02:00
Manuel Schiller
c992495bf4
feat: match params (#7263) 2026-04-30 19:47:07 +02:00
neverland
a5385dbd90
chore(deps): update Rsbuild related deps to v2.0.1 (#7245) 2026-04-24 22:41:31 +02:00
Manuel Schiller
105d05691a
fix(router-generator): harden route file transform rewrites (#7167) 2026-04-13 02:20:50 +02:00
Manuel Schiller
42c3f3b3a3
fix: scroll restoration upon browser forward navigation (#7055) 2026-03-27 01:24:06 +01:00
Manuel Schiller
cf5f554247
fix: scroll restorating without throttling (#7042) 2026-03-26 18:00:55 +01:00
Birk Skyum
b1c0f4602d
chore: upgrade tooling to typescript 6 (#7024) 2026-03-23 22:59:52 +01:00
Flo
054523900b
refactor: signal based reactivity (#6704) 2026-03-20 10:33:28 +01:00
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