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

2,225 commits

Author SHA1 Message Date
github-actions[bot]
dc5a404eb9
ci: Version Packages (#8048)
ci: changeset release

Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
2026-08-12 11:15:35 +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
github-actions[bot]
e15bda5c4d
ci: Version Packages (#8040)
ci: changeset release

Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
2026-08-12 10:33:33 +02:00
Flo
f5007607d6
fix(router): warn when Outlet is rendered in fallback components (#8045) 2026-08-12 09:53:15 +02:00
Flo
aa10b6589e
fix(router): apply preload delay to viewport links (#8044)
* fix(router): apply preload delay to viewport links

* fix(router): cancel delayed viewport preloads on exit

* fix(router): process queued viewport transitions in order

* fix(router): use latest queued viewport state

* refactor(router): inline viewport observer options

* fix(router): stabilize viewport preload timers

* cleaner timeout map key
2026-08-12 09:52:36 +02:00
Flo
1aafca9b45
refactor: remove Link transition state (#8043) 2026-08-12 09:52:10 +02:00
github-actions[bot]
91a848e979
ci: Version Packages (#8021)
ci: changeset release

Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
2026-08-09 20:43:56 +02:00
Flo
5500fd3510
fix(router-core): handle excessive parent relative links (#8018) 2026-08-09 19:40:25 +02:00
github-actions[bot]
6f8f534bf3
ci: Version Packages (#8011)
ci: changeset release

Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
2026-08-09 11:01:57 +02:00
Manuel Schiller
c568caf3f3
inline isServer for proper DCE (#7996) 2026-08-08 09:54:57 +02:00
github-actions[bot]
2265129b40
ci: Version Packages (#7994)
ci: changeset release

Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
2026-08-07 19:58:00 +02:00
Mat Clayton
95dec51018
perf(react-router): bail out of Link re-renders when href and active state are unchanged (#7952)
* perf(react-router): bail out of Link re-renders when href and active state are unchanged

useLinkProps subscribes to the location store with an identity selector and an
href comparator, then derives href and isActive from the published location in
downstream memos. The comparator can only ask "is this a different URL?", never
"does this link care?", so every Link on the page re-renders on every navigation.

Move the location-derived values into the selector and compare them, so a link
whose resolved href and active state are unaffected by a navigation bails out.
buildLocation still runs once per link per location change; what goes away is the
React render and the host reconciliation under it.

doPreload no longer pre-supplies _builtLocation, because the built location is no
longer kept in render state. preloadRoute already falls back to building it, which
is what handleClick has always relied on for router.navigate.

The isActive and externalLink bodies move to module-level helpers unchanged so the
selector stays readable; activeOptions is spread into its four primitive fields in
the dependency list because callers routinely pass an inline object literal.

* refactor: trim redundant comments and brace single-line bodies

The comments explained the bail-out rationale twice — once on the LinkState type
and again above the selector — and two helper docblocks restated their function
names. The rationale now appears once, where a reader meets the selector; the
detail belongs in the PR description rather than the source.

Also braces the three single-line if bodies, per the AGENTS.md rule that if/else
bodies always use curly braces.

* refactor: publish link state as a tuple

The type is erased either way, but the object literal's property names survive
minification and a tuple's positions don't — so this drops three property names
from the selector's return plus the three property reads in compareLinkState.

Measured on the unminified build: -54 bytes in dist/esm/link.js and the same in
dist/cjs/link.cjs.

* test: assert the published link state, and drop a redundant cast

The render-count assertions proved the bail-out but not that the selector still
publishes correct values, so a selector returning a constant could have passed.
The test now also asserts that the link gaining active state carries
`data-status="active"` afterwards (and does not beforehand), and that the
unaffected link keeps its href and stays inactive.

Checked by sabotaging the selector: returning a constant tuple with a wrong href
but a correct active state now fails, where previously it passed.

Also drops `as any` from `new URL(to)` in resolveExternalLink — the guard above
already narrows `to` to string.

* refactor: pass activeOptions through instead of destructuring

Depends on the four fields rather than the object, with an exhaustive-deps
disable: callers routinely pass an inline literal, which would otherwise rebuild
the selector every render. resolveIsActive reads only those four fields, so the
disable is not hiding a live dependency.

-269 bytes on each of dist/esm/link.js and dist/cjs/link.cjs (unminified).

* perf: memoize the href derivation on the built href

The `useMemo` chain this replaced keyed `getHrefOption` and the external-link
resolution on the href string, so a navigation that left a link's href alone
skipped both. Deriving everything in the selector ran them on every location
notification instead, which showed up as a ~10% regression on the client-nav
rewrites benchmark, where rewrite handling makes `getHrefOption` expensive.

Cache both on the built href inside the selector closure. Measured on a
five-link root layout, per navigation: getHrefOption drops from 5 calls back to
0, matching the pre-change profile, with buildLocation and the active-state
derivation unchanged at 5.

* perf: keep _options referentially stable while its contents are equal

Links commonly pass inline `params` / `search` object literals. Those change
identity on every parent render, which rebuilt `_options`, which changed the
store selector's identity, which discarded useSyncExternalStoreWithSelector's
memoized selection. buildLocation then ran twice per navigation: once in the
notification check and once in the render-phase selection.

Measured on a replica of the client-nav rewrites scenario (six links, root
subscribed to the pathname via useLocation), buildLocation per navigation:
base 7, before this commit 12, after 7.

* revert: drop the href memoization, it measured no benefit

Reverts 409371b. It did cut getHrefOption from 5 calls per navigation to 0,
matching the pre-change profile, but that is not where the time went: on the
rewrites scenario it moved the number by 0.05% (medians 245.33 vs 245.21 hz over
four interleaved rounds). Not worth ~15 lines of mutable closure state.

The rewrites regression is fixed by the _options stabilisation instead.

* docs: explain why useValueStable exists

Replaces a leftover scratch note.

* perf: cut the bundle cost of the link state selector

Stabilise `activeOptions` with the same helper used for `search` / `params`,
so the selector depends on one value instead of four destructured fields. That
also makes the dependency array honest, so the exhaustive-deps disable goes.

Drop the reference-equality guard in useValueStable: deepEqual already
short-circuits on `a === b`, so the guard only saved a function call that
returns immediately.

Measured with benchmarks/bundle-size against this branch's base, gzip delta
across the eight React scenarios moves from +27/-7 to +11/-24, and raw bytes go
uniformly negative (-37 to -45 on every scenario).

* perf: pass _options to preloadRoute without the shallow clone

The spread existed to add _builtLocation, which is gone, and nothing on the
preload path mutates the options object: preloadRoute only reads
opts._builtLocation, build() only reads dest fields, and the search middleware
chain only reads dest.search. Search middlewares themselves receive
{ search, next }, never dest.

Saves an object allocation per hover. Bytes are unchanged on gzip, -5 raw.

* fix: do not collapse explicit-undefined params when stabilising link options

useValueStable compared with deepEqual's default ignoreUndefined: true, which
skips undefined-valued keys on both sides, so `{}` and `{ category: undefined }`
compared equal. Those build different locations: an explicit undefined clears an
inherited optional param while an empty object inherits it. A Link whose params
changed from one to the other kept publishing the stale href, and click and
preload used the stale options too.

Compare with ignoreUndefined: false. Adds a regression test covering the
/posts/tech -> /posts transition, which fails before this commit and passes
after, and passes on the pre-PR baseline.

* chore: empty commit to re-trigger CI

* chore: add changeset

---------

Co-authored-by: Flo <me@florianpellet.com>
2026-08-07 17:37:30 +02:00
github-actions[bot]
995bd97a9f
ci: Version Packages (#7993)
ci: changeset release

Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
2026-08-07 13:04:38 +02:00
Flo
ea3a665d81
fix(router): retain mounted UI during revalidation (#7992)
* fix(router): retain mounted UI during revalidation

* fix(router): preserve initial pending presentation

* changeset

* test(router): make retained pending tests deterministic

* complete solid/vue suite
2026-08-07 11:57:59 +02:00
github-actions[bot]
ac1d0abea9
ci: Version Packages (#7968)
ci: changeset release

Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
2026-08-06 15:38:36 +02:00
Flo
2435885fa8
Create file routes directly (#7970)
* test createFileRoute factory behavior

* create file routes directly

* preserve createFileRoute parameter name

* cleanup

* changeset
2026-08-06 13:38:43 +02:00
Flo
86bf510c29
Pass intersection observer disabled state directly (#7971)
* test disabled viewport links in Vue

* test reactive intersection observer disabling

* pass intersection observer disabled state directly

* changeset
2026-08-06 13:38:04 +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
07a3d10d8f
fix(router): preserve raw params for match identity (#7966)
* fix(router): preserve raw params for match identity

* refactor(router): return matched routes as tuple

* ci: apply automated fixes

---------

Co-authored-by: autofix-ci[bot] <114827586+autofix-ci[bot]@users.noreply.github.com>
2026-08-05 21:41:42 +02:00
github-actions[bot]
790e062820
ci: Version Packages (#7963)
ci: changeset release

Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
2026-08-05 20:18:34 +02:00
github-actions[bot]
704145c6d5
ci: Version Packages (#7946)
ci: changeset release

Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
2026-08-04 22:25:17 +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
Alem Tuzlak
b5e540d74a
docs: use the dynamic README header endpoint (#7940)
* docs: use the dynamic README header endpoint

* docs: add README header banners to the framework adapter packages
2026-08-03 21:03:29 +02:00
Tanner Linsley
179d9b9b5e
Improve Router and Start agent skills (#7867)
* docs: improve Router and Start agent skills

* docs: address agent skill review feedback

* ci: apply automated fixes

* docs: align agent skills with intent schema

---------

Co-authored-by: autofix-ci[bot] <114827586+autofix-ci[bot]@users.noreply.github.com>
2026-07-26 10:53:49 -06:00
Manuel Schiller
88f366ab8e
chore: migrate to typescript 7 (#7887) 2026-07-23 23:10:51 +02:00
Flo
3a5575627d
test: add regression coverage for existing router behavior (#7886) 2026-07-23 22:13:21 +02:00
Flo
0b178a79e2
test: add more regression coverage for existing router behavior (#7822) 2026-07-15 09:48:19 +02:00
Flo
11a6a0d8ba
test: add regression coverage for existing router behavior (#7812) 2026-07-14 01:44:02 +02:00
github-actions[bot]
58c005fcb1
ci: Version Packages (#7811) 2026-07-13 23:31:08 +02:00
github-actions[bot]
ecbbd9a8ec
ci: Version Packages (#7676)
ci: changeset release

Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
2026-07-01 23:33:19 +02:00
github-actions[bot]
f23ed0fe73
ci: Version Packages (#7576) 2026-06-17 00:12:54 +02:00
Flo
689c5ab32e
chore(react-router): silence AbortError in renderRouterToStream (#7627) 2026-06-13 19:41:02 +02:00
dfedoryshchev
a2b9d51b0a
docs: fix duplicate "to" typos (#7370) 2026-06-12 22:55:18 +02:00
Flo
56bd271ba0
perf(react-router): add match selector compares (#7596)
* perf(react-router): add match selector compares

* fix scroll restoration

* Revert "fix scroll restoration"

This reverts commit 620e9674fa.

* fix scroll restoration

* lint rules of hooks
2026-06-11 10:04:11 +02:00
Flo
52db7034fd
fix(react-router): avoid throwing in useMatch selector (#7595)
* fix(react-router): avoid throwing in useMatch selector

* lint fix and changeset
2026-06-10 22:11:08 +02:00
Flo
689d88e04c
refactor(react-router): Reduce bundle size by sharing hook structuralSharing logic (#7577) 2026-06-07 19:29:16 +02:00
Flo
4a93cffffc
refactor(react-router): useMatches skips useRef during SSR (#7575) 2026-06-07 13:26:37 +02:00
github-actions[bot]
10a7ff833c
ci: Version Packages (#7563) 2026-06-06 11:49:34 +02:00
github-actions[bot]
996b9bee38
ci: Version Packages (#7561) 2026-06-06 10:45:35 +02:00
github-actions[bot]
65ad9062ea
ci: Version Packages (#7556) 2026-06-06 01:01:21 +02:00
github-actions[bot]
a8647d20a1
ci: Version Packages (#7554) 2026-06-05 22:11:34 +02:00
Ulrich Stark
fee0b58c51
refactor: remove unused dependencies (#7541) 2026-06-04 22:47:41 +02:00
Ulrich Stark
bb99f66a47
refactor: remove unnecessary any assertions (#7542) 2026-06-04 22:12:45 +02:00
github-actions[bot]
7fc7c346dc
ci: Version Packages (#7525)
ci: changeset release

Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
2026-06-02 22:50:10 +02:00
github-actions[bot]
0ac831bdf7
ci: Version Packages (#7508) 2026-05-30 02:44:11 +02:00
Manuel Schiller
2f5374945e
fix: fix primitive beforeLoad errors (#7505)
* fix: fix primitive beforeLoad errors

* ci: apply automated fixes

---------

Co-authored-by: autofix-ci[bot] <114827586+autofix-ci[bot]@users.noreply.github.com>
2026-05-30 01:29:42 +02:00
github-actions[bot]
8b3659143f
ci: Version Packages (#7504)
ci: changeset release

Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
2026-05-29 02:32:18 +02:00
Manuel Schiller
d1997b66d7
fix: fix streaming (#7497) 2026-05-29 02:27:23 +02:00
github-actions[bot]
658c224145
ci: Version Packages (#7478) 2026-05-24 02:15:23 +02:00
Manuel Schiller
51a97a167f
feat(start): support rsbuild iife client output (#7477) 2026-05-24 02:02:05 +02:00