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

6,711 commits

Author SHA1 Message Date
Maximilian
e9d4c5b674
chore: fix typo and move route callback for start-workos example (#5048)
Co-authored-by: SeanCassiere <33615041+SeanCassiere@users.noreply.github.com>
2025-09-05 08:40:27 +12:00
autofix-ci[bot]
df4abd267a
ci: apply automated fixes 2025-09-04 20:26:58 +00:00
Nitin Gupta
f8f47d59aa
Added Prisma as a partner in relevant places (#5086)
Inserted relevant logo files and/or blurbs re: Prisma Postgres in the
relevant places. Please review and edit as you see fit.

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

- Documentation
- Added a Prisma partner tile to the Partners section, linking to
prisma.io with tracking parameters and logo.
- Introduced a Prisma Postgres subsection in the React databases guide
with dark/light logos, feature highlights (edge-optimized, fits your
stack, web UI, auto-scaling, unikernel isolation), and CTAs; placed
after Neon.
- Added Prisma to the TanStack Start funded partners overview with logo
and description, positioned between Neon and Convex.
  - No functional or API changes.
<!-- end of auto-generated comment: release notes by coderabbit.ai -->

---------

Co-authored-by: coderabbitai[bot] <136622811+coderabbitai[bot]@users.noreply.github.com>
Co-authored-by: Tanner Linsley <tannerlinsley@gmail.com>
2025-09-04 14:26:10 -06:00
Tanner Linsley
e02201312d release: v1.131.35 v1.131.35 2025-09-04 08:48:41 +00:00
Nico Lynzaad
cb0b6928d6
fix(router-core): reduce maskedLocation builds (#5081)
As highlighted by #5062 when using a mask, the location is being built
multiple times.

While we need to build the next path as well as the mask, the mask is
being built twice. this PR fixes that by using the first build of the
mask as the maskedLocation for the next path.

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

## Summary by CodeRabbit

* **Refactor**
* Optimized routing logic to avoid redundant work when applying masked
destinations, reducing unnecessary computation during navigation. No
changes to behavior or public APIs.

<!-- end of auto-generated comment: release notes by coderabbit.ai -->
2025-09-04 10:47:08 +02:00
autofix-ci[bot]
f158256bd4
ci: apply automated fixes 2025-09-03 23:41:01 +00:00
HaydenB
540a2bd8a1
docs: Adding note regarding yarn workspace usage (#5073) 2025-09-04 01:40:11 +02:00
Tanner Linsley
8196ba1573 release: v1.131.34 v1.131.34 2025-09-03 19:55:59 +00:00
Flo
3db4eb98ee
refactor(router-core): isMatch perf (#5075)
idk when this function is used, but this is an easy win

```sh
 ✓  @tanstack/router-core  tests/match-by-path.bench.ts > isMatch 3251ms
     name                           hz     min     max    mean     p75     p99    p995    p999     rme  samples
   · new implementation  10,695,733.21  0.0000  1.0057  0.0001  0.0001  0.0001  0.0002  0.0003  ±0.43%  5347867   fastest
   · old implementation   7,647,886.94  0.0000  0.1493  0.0001  0.0001  0.0002  0.0002  0.0003  ±0.08%  3823944

 BENCH  Summary

   @tanstack/router-core  new implementation - tests/match-by-path.bench.ts > isMatch
    1.40x faster than old implementation
```

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

## Summary by CodeRabbit

* **Refactor**
* Optimized internal path-matching logic to reduce array mutations and
improve performance during route resolution.
* Improves efficiency and lowers memory churn in navigation-heavy
scenarios.
  * No changes to expected behavior or public APIs.

<!-- end of auto-generated comment: release notes by coderabbit.ai -->
2025-09-03 21:49:28 +02:00
Flo
777e152d9f
refactor(router-core): redirect doesn't need to create an empty object for headers init (#5076)
<!-- This is an auto-generated comment: release notes by coderabbit.ai
-->

## Summary by CodeRabbit

* **Refactor**
* Streamlined header initialization in redirect handling to rely on
default behavior when no headers are provided.
* Improves consistency and reduces implicit assumptions in header
processing without altering existing behavior.

* **Chores**
* Minor internal cleanup to align with standard header handling
patterns.

No functional changes are expected for end-users; redirects and related
headers continue to behave as before.

<!-- end of auto-generated comment: release notes by coderabbit.ai -->
2025-09-03 21:48:47 +02:00
Tanner Linsley
453790b723 release: v1.131.33 v1.131.33 2025-09-03 16:51:07 +00:00
Flo
dc45979f1f
fix(router-core): replaceEqualDeep works w/ null prototype objects (#5080)
Fix https://github.com/TanStack/router/issues/5078

I had not pushed this before because ESLint was angry w/ me, and now
stuff breaks :'(

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

## Summary by CodeRabbit

* **Bug Fixes**
* Improved reliability when comparing and updating objects with null
prototypes, addressing edge-case behavior and preventing unexpected
failures.
* Hardened own-property checks to behave consistently across different
object shapes.
  * No changes to the public API.

* **Tests**
* Added coverage for handling objects created without a prototype to
ensure correct comparison and update behavior.

<!-- end of auto-generated comment: release notes by coderabbit.ai -->
2025-09-03 18:49:41 +02:00
hokkyss
bc5e78f04c
docs(start): environment functions for createIsomorphicFn and envOnly (#4806) 2025-09-03 15:40:25 +12:00
Manuel Schiller
31783149e5 docs: document shellComponent 2025-09-02 20:55:42 +02:00
Tanner Linsley
fec3509d7a release: v1.131.32 v1.131.32 2025-09-02 12:31:46 +00:00
Flo
ad3ab7fbb6
refactor(router-core): unify replaceEqualDeep implementation w/ query (#5067)
Following https://github.com/TanStack/query/pull/9604, this PR
replicates the implementation of `replaceEqualDeep` here, so that both
are more similar (avoid drifting apart over time).

There are no performance changes.

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

## Summary by CodeRabbit

- Performance
- Optimized internal deep-compare and replacement logic to short-circuit
equal values and avoid unnecessary recursion, improving route state
updates. Users may see faster navigations and reduced CPU usage in
complex scenarios.

- Refactor
- Simplified internal implementation while preserving existing behavior
and public APIs. No functional changes or breaking changes for
consumers.

<!-- end of auto-generated comment: release notes by coderabbit.ai -->
2025-09-02 14:30:20 +02:00
autofix-ci[bot]
5b5f792e3f
ci: apply automated fixes 2025-09-01 17:29:58 +00:00
Noah Silas
0ee993b09e
docs: Use named component in react quick-start (#5061) 2025-09-01 19:29:04 +02:00
Tanner Linsley
79fe58fdef release: v1.131.31 v1.131.31 2025-08-31 11:51:05 +00:00
Nico Lynzaad
fb04dafb21
fix(react-router, solid-router): reduce useNavigate reactivity on path changes (#5037)
This is a follow-up to #4978.

As picked up by @Sheraff the changes made caused useNavigate to
negatively impact performance specifically with useNavigate being too
reactive to path changes.

This reverts the use of useActiveLocation, that acted as a single
implementation of the logic to determine the from location, and moves
the determination of the from path back to each of Link and useNavigate.
While the core logic is still the same across the implementations the
implication of how it's used and the sources of the required inputs are
different enough that it warrants separate implementations.

This PR does not revert the full change set and still applies to core
reasons and changes for the previous commit in keeping the logic for
determining the from clause the same, i.e. the order of determining the
from path for navigation remains: from clause => current location =>
rendered location.

@Sheraff to advise if this implementation resolves the issues he picked
up.



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

* Breaking Changes
* Removed active-location hooks and their associated types from React
and Solid packages.
* Refactor
* Link and navigation now accept an explicit "from" option instead of
deriving it from active-location state.
* New Features
* Added a programmatic Navigate helper for Solid to trigger navigation
on mount.
* Bug Fixes
* More predictable fallback behavior when no explicit "from" is
provided.
* Performance
  * Reduced state subscriptions for minor efficiency gains.
<!-- end of auto-generated comment: release notes by coderabbit.ai -->

---------

Co-authored-by: autofix-ci[bot] <114827586+autofix-ci[bot]@users.noreply.github.com>
2025-08-31 13:48:25 +02:00
Tanner Linsley
d872397a26 release: v1.131.30 v1.131.30 2025-08-30 13:22:55 +00:00
Flo
eb6bcea03b
refactor(router-core): slightly faster replaceEqualDeep (#5046)
## Description

Improve performance of this function that gets called a lot for
structural sharing. Main improvements are
- avoid creating object when possible
(`Object.keys().concat(Object.getOwnPropertySymbols())` creates 3
arrays, when we only want 1)
- instantiating array to the correct size avoids a lot of memory
management under the hood (prefer `new Array(size)` over `[]`)
- avoid reading the same value many times on an object, store is as a
const

More minor changes (not 100% sure I can measure it, but I think so):
- using `keys.includes(k)` is slower than
`Object.hasOwnProperty.call(obj, k)` or `obj.hasOwnProperty(k)`

## benchmark

TL;DR: consistently 1.3x faster implementation

```ts
describe('replaceEqualDeep', () => {
  bench('old implementation', () => {
    replaceEqualDeepOld({ a: 1, b: [2, 3] }, { a: 1, b: [2, 3] })
    replaceEqualDeepOld({ a: 1, b: [2, 3] }, { a: 2, b: [2] })
  })

  bench('new implementation', () => {
    replaceEqualDeep({ a: 1, b: [2, 3] }, { a: 1, b: [2, 3] })
    replaceEqualDeep({ a: 1, b: [2, 3] }, { a: 2, b: [2] })
  })
})
```
```sh
 ✓  @tanstack/router-core  tests/utils.bench.ts > replaceEqualDeep 1540ms
     name                          hz     min     max    mean     p75     p99    p995    p999     rme  samples
   · old implementation  1,040,201.62  0.0008  0.7638  0.0010  0.0010  0.0013  0.0016  0.0022  ±0.33%   520101
   · new implementation  1,347,988.70  0.0006  2.4037  0.0007  0.0007  0.0010  0.0010  0.0013  ±0.95%   673995   fastest

 BENCH  Summary

   @tanstack/router-core  new implementation - tests/utils.bench.ts > replaceEqualDeep
    1.30x faster than old implementation
```

---

The `replaceEqualDeep` implementation before this PR handles Symbol
keys, and non-enumerable keys (see
https://github.com/TanStack/router/pull/4237), but **not** keys that are
both a Symbol and non-enumerable.

This PR fixes this issue. But if we also fix it in the previous
implementation before comparing performance we get a bigger perf diff
```sh
 ✓  @tanstack/router-core  tests/utils.bench.ts > replaceEqualDeep 1471ms
     name                          hz     min     max    mean     p75     p99    p995    p999     rme  samples
   · old implementation    713,964.88  0.0012  0.7880  0.0014  0.0014  0.0019  0.0023  0.0050  ±0.35%   356983
   · new implementation  1,319,003.07  0.0006  5.0000  0.0008  0.0007  0.0010  0.0016  0.0050  ±1.96%   659502   fastest

 BENCH  Summary

   @tanstack/router-core  new implementation - tests/utils.bench.ts > replaceEqualDeep
    1.85x faster than old implementation
```


---



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

* **Bug Fixes**
* Change detection now includes symbol-keyed properties, treats
undefined/missing entries consistently, and avoids processing objects
with non-enumerable own properties to prevent incorrect updates.
  * No public API changes.

* **Performance**
* Equality/merge logic reuses unchanged values more reliably and
improves array update handling by allocating appropriately, reducing
unnecessary work.
<!-- end of auto-generated comment: release notes by coderabbit.ai -->

---------

Co-authored-by: autofix-ci[bot] <114827586+autofix-ci[bot]@users.noreply.github.com>
2025-08-30 15:16:20 +02:00
Flo
48551b357a
refactor(router-core): slightly faster deepEqual (#5051)
## description
- inline `getObjectKeys` as regular control flow inside `deepEqual` to
be able to skip as much work as possible, and create fewer objects
- using a regular `for` loop for the array case to skip the overhead of
using native array iterators w/ the `.every()` or `.some()` methods
- check `Array.isArray` before `isPlainObject` because this check is
cheaper
- `opts.partial` is a special case that allows us to skip a bunch of
work, so we give it its own branch

## benchmark

TL;DR: consistently 1.7x faster implementation

```ts
describe.only('deepEqual', () => {
  bench('old implementation', () => {
    deepEqualOld({ a: 1, b: [2, 3] }, { a: 1, b: [2, 3] }, {partial: true})
    deepEqualOld({ a: 1, b: [2, 3] }, { a: 2, b: [2] })
  })

  bench('new implementation', () => {
    deepEqual({ a: 1, b: [2, 3] }, { a: 1, b: [2, 3] }, {partial: true})
    deepEqual({ a: 1, b: [2, 3] }, { a: 2, b: [2] })
  })
})
```

```sh
 ✓  @tanstack/router-core  tests/utils.bench.ts > deepEqual 2484ms
     name                          hz     min     max    mean     p75     p99    p995    p999     rme  samples
   · old implementation  3,806,354.20  0.0002  4.3084  0.0003  0.0003  0.0005  0.0007  0.0013  ±1.78%  1903178
   · new implementation  6,978,154.05  0.0001  0.1937  0.0001  0.0002  0.0002  0.0002  0.0003  ±0.15%  3489078   fastest

 BENCH  Summary

   @tanstack/router-core  new implementation - tests/utils.bench.ts > deepEqual
    1.83x faster than old implementation
```

----

This PR also adds test cases for using `deepEqual` w/ objects containing
Symbol and non-enumerable keys. The behavior for those was not changed
in this PR, we're just documenting it: they are simply ignored.

----

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

* **Bug Fixes**
* Improved deep-equality checks for arrays and object comparisons;
ignore-undefined handling clarified and made more consistent.

* **Refactor**
* Iteration and comparison logic reorganized for earlier
short-circuiting; behavior around enumerable (including inherited) keys
adjusted; no public API changes.

* **Tests**
* Added tests demonstrating edge cases with symbol/non-enumerable
properties and prototype augmentation (marked as expected failures).
<!-- end of auto-generated comment: release notes by coderabbit.ai -->

---------

Co-authored-by: autofix-ci[bot] <114827586+autofix-ci[bot]@users.noreply.github.com>
2025-08-30 15:16:06 +02:00
Tanner Linsley
90e900613c release: v1.131.29 v1.131.29 2025-08-29 19:37:54 +00:00
Karolis Užkuraitis
4b792b923b
fix(solid-router): RouteProvider Wrap and Match InnerWrap support propagating context to their children (#5033)
Refactored a bit router options.Wrap and options.InnerWrap usage in
RouterProvider and Match components.
Now they will be able to provide context for their children components.

Added few tests for scenarios that were failing before.

Fixes #3744

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

* New Features
* Consistent wrapper handling across routing so routed content and
pending states share the same wrapper/context without adding extra DOM
nodes.
* Exposed createMemoryHistory for memory-based routing in apps and
tests.

* Refactor
* Simplified suspense and wrapper handling for clearer, safer rendering
behavior.

* Tests
* Added tests verifying context propagation through wrappers and into
pending (fallback) states.
<!-- end of auto-generated comment: release notes by coderabbit.ai -->

---------

Co-authored-by: autofix-ci[bot] <114827586+autofix-ci[bot]@users.noreply.github.com>
2025-08-29 21:24:38 +02:00
Tanner Linsley
a98c89c5e2 release: v1.131.28 v1.131.28 2025-08-26 17:32:10 +00:00
Nico Lynzaad
2df8e52ba0
fix(Relative routing): Default relative routing to current location (#4978)
When using relative routing we have 3 things to consider:

1) Is this relative to the current location? This is specifically
relevant for using `to="."` and `to=".."` in layout routes
2) Is this relative to the rendered route location?
3) Should this be relative to some other route in the tree

We have had a few issues where it hasn't been clear how relative routing
is applied in various scenarios, and where the application differs, for
example `to="."` and `to=".."` was treated differently.

This PR applies the following:
1) when no from path is specified, navigation is done from the current
location, this does not affect absolute paths but makes relative paths
more standardised.
2) other relative navigations require a from location to be specified.

This is achieved by setting Link and useNavigate to default to the
current active location instead of the rendered route location. This
also simplifies the logic in buildLocation as we no longer specifically
cater for `to="."`.

Included in this PR is the required changes to router-core
(buildLocation), react-router and solid-router (Link and useNavigate),
tests for both react-router and solid-router and an update to the docs
to clarify the usage.

This closes #4842

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

* **New Features**
* Added active-location hooks, origin-aware navigation helpers,
programmatic Route API for Link generation, browser-history utilities,
optional from origin for Navigate, and route fullPath exposure.

* **Bug Fixes**
* More deterministic relative navigation (., ..) resolution,
preservation of search/params, and runtime warnings for invalid origins.

* **Documentation**
  * Clarified relative-link semantics and updated examples.

* **Tests**
* Vastly expanded end-to-end coverage for relative navigation, masking,
basepath, and trailing-slash permutations.
<!-- end of auto-generated comment: release notes by coderabbit.ai -->

---------

Co-authored-by: autofix-ci[bot] <114827586+autofix-ci[bot]@users.noreply.github.com>
2025-08-26 19:30:31 +02:00
Lee
81346508fd
docs: add guide for edit docs and preview in local (#5005) 2025-08-24 22:35:00 +02:00
Flo
9cc216b41c
test(react-router): add more variants to store-updates test (#5019)
Add a few more setup configurations to measure the number of `__store`
updates:
- with caching (`staleTime > 0`)
- when preloading multiple times the same route (simulates hovering a
list of links to the same page w/ different params)

---------

Co-authored-by: autofix-ci[bot] <114827586+autofix-ci[bot]@users.noreply.github.com>
2025-08-23 16:26:36 +02:00
Cory House
40f9ab7157
Refine wording in external data loading guide (#5015) 2025-08-23 08:01:54 +02:00
Flo
3f05c0b16b
test(router-core): fix flakiness of store-updates 'preload then navigate' test (#4995)
It turns out the 'hover preload, then navigate, w/ async loaders' test
in
`packages/react-router/tests/store-updates-during-navigation.test.tsx`
was sometimes (but very rarely) yielding 16 updates instead of the
expected 15. This PR makes minimal changes to this test so that it's now
reliably 14.

I'm not exactly sure where we lost that 1 update, so we might not be
measuring exactly the same thing. But it's still worth it to have a
robust test suite.

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

## Summary by CodeRabbit

* **Tests**
* Improved reliability of hover preloading and navigation behavior tests
by introducing realistic loader delays and aligning interaction timing,
reducing flakiness.
* Updated assertions for store updates during navigation to reflect
observed behavior, ensuring more stable and predictable test outcomes.

<!-- end of auto-generated comment: release notes by coderabbit.ai -->
2025-08-19 09:18:47 +02:00
Tanner Linsley
83ab17331b release: v1.131.27 v1.131.27 2025-08-19 06:53:58 +00:00
Flo
da22c5a6c8
refactor(router-core): scroll-restoration minor performance cleanup (#4990)
Some minor performance improvements in `scroll-restoration.ts`
- in `getCssSelector`: 
- we can obtain `indexOf` without creating an empty array through
`Array.prototype.indexOf`
- using `.unshift` in a loop is always bad for performance. To build
arrays in reverse, use `.push()` in the loop, and `.reverse()` at the
end.
- in `restoreScroll`: 
- we can early exit without creating an IIFE by using a [labeled
statement](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Statements/label)
- we can avoid creating an array of elements to iterate over since we
already have an array
- in `onScroll`: 
- we can avoid accessing the same key twice by using the `||=` operator

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

## Summary by CodeRabbit

- New Features
  - None
- Bug Fixes
  - More reliable scroll restoration after navigation and refresh.
- Improved handling of URL hash anchors for accurate in-page scrolling.
  - Consistent scroll-to-top behavior across configured elements.
- Avoids runtime errors when session storage is unavailable or data is
invalid.
- Refactor
- Streamlined scroll handling and state initialization for improved
stability and minor performance gains.

<!-- end of auto-generated comment: release notes by coderabbit.ai -->

---------

Co-authored-by: autofix-ci[bot] <114827586+autofix-ci[bot]@users.noreply.github.com>
2025-08-19 08:45:35 +02:00
Flo
5134aa286d
refactor(router-core): shouldExecuteBeforeLoad is always true (#4992)
Fix https://github.com/TanStack/router/pull/4971#discussion_r2282953542

With the code now simplified by previous PRs, we noticed that the
`shouldExecuteBeforeLoad` guard is always true, so we can clean it up.

In a follow up PR, we'll revise the conditions under which a
`beforeLoad` should be called or skipped.

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

## Summary by CodeRabbit

* **Refactor**
* Streamlined pre-load checks and execution flow, reducing branching and
improving consistency across client and server rendering.
* Unified orchestration of the before-load phase to simplify control
flow and improve maintainability.

* **Bug Fixes**
* More reliable handling of redirects and “not found” states during
preloading, preventing unintended execution paths and improving
navigation stability.

<!-- end of auto-generated comment: release notes by coderabbit.ai -->

---------

Co-authored-by: autofix-ci[bot] <114827586+autofix-ci[bot]@users.noreply.github.com>
2025-08-19 08:43:55 +02:00
Flo
a7504ae79e
refactor(router-core): simplify defaultParseSearch & defaultStringifySearch (#4985)
Wait for this PR before merging:
https://github.com/TanStack/router/pull/4987. It adds unit tests that
should help make sure we're not breaking anything here.

--- 

The functions used to serialize and deserialize search params are called
*a lot*, but they are creating many unnecessary objects. This PR
refactors
- `encode` to be only as generic as what we need => in practice we only
need to handle 1 value per key (i.e. `.set()` and not `.append()`) so we
don't need a special case for arrays
- `decode` can avoid creating many arrays
- `stringifySearchWith` (and `defaultStringifySearch`) don't need to
pre-stringify the input into a `<string,string>` dictionary as `encode`
now accepts a stringifier function


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

- Breaking Changes
- Removed encode and decode from React Router and Solid Router public
exports.
  - Query string prefix support removed in encode/decode.
- Refactor
- Updated query string handling: arrays encode as comma-separated
values; duplicate keys decode into arrays.
- Streamlined error handling and avoided input mutation; consistent
leading “?” management.
- Tests
- Updated tests to match new encoding/decoding behavior and removed
prefix-related cases.
<!-- end of auto-generated comment: release notes by coderabbit.ai -->

---------

Co-authored-by: autofix-ci[bot] <114827586+autofix-ci[bot]@users.noreply.github.com>
2025-08-19 08:42:53 +02:00
Flo
f1c13a04e3
test(router-core): add search param serialization / deserialization unit tests (#4987)
Just some tests for `defaultParseSearch` and `defaultStringifySearch`,
because they're used a lot and are very public and can handle user
inputs (as in final human users, not devs).

These tests are just documentation of the current behavior.

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

* **Tests**
* Added a comprehensive test suite for URL query-string
serialization/deserialization covering empty values, primitives,
complex/nested structures, special characters, circular/self-references,
and unusual inputs (e.g., Number/String objects, Promise, Date).
* Verifies round-trip isomorphism and behavior when parsing externally
sourced or malformed query strings.
  * No public API changes and no user-facing changes.
<!-- end of auto-generated comment: release notes by coderabbit.ai -->

---------

Co-authored-by: autofix-ci[bot] <114827586+autofix-ci[bot]@users.noreply.github.com>
2025-08-19 08:16:58 +02:00
Tanner Linsley
f2190d77ba release: v1.131.26 v1.131.26 2025-08-18 07:56:53 +00:00
Flo
2c1f8b94f4
refactor(router-core): redirect skips creating a URL object if href is not a string (#4986)
Creating a `URL` object is a little expensive, and we know it's going to
throw if `href` is not a string. So we can skip it entirely in that case
(which is probably most cases?).

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

## Summary by CodeRabbit

* **Bug Fixes**
* Improved redirect handling to avoid errors when a URL is missing or
invalid.
* Added safeguards to prevent runtime crashes when redirect data is
null.
  * Enhanced URL parsing reliability during redirects.
  * No changes to public APIs.

<!-- end of auto-generated comment: release notes by coderabbit.ai -->
2025-08-18 09:55:32 +02:00
Tanner Linsley
fa3f8faf45 release: v1.131.25 v1.131.25 2025-08-17 19:27:38 +00:00
Flo
a7b1667827
refactor(router-core): remove pick utility in favor of direct object manipulation (#4983)
Based on the current usage of `pick`, directly addinf the picked keys to
the objects will be less overhead with the same result.

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

- Refactor
- Simplified internal routing logic related to navigation options; no
change to runtime behavior.
- Chores
  - Removed an internal utility no longer used.
- Public API
- One non-essential utility export was removed from package entry
points, slightly reducing the public API surface.
<!-- end of auto-generated comment: release notes by coderabbit.ai -->
2025-08-17 21:26:07 +02:00
Tanner Linsley
472cac4ae4 release: v1.131.24 v1.131.24 2025-08-17 16:43:55 +00:00
Flo
642964e4e3
refactor(router-core): reduce buildLocation object allocations (#4981)
When we can (and it's reasonable), it's always beneficial to reduce the
number of objects we create in JS, so as to minimize the memory pressure
and the GC work.

`buildLocation` gets called pretty often, so removing a few object
allocations can be very beneficial (especially inside loops).

Also, from a purely "immediate performance" point of view,
`Object.assign` tends to be faster than `{...foo}`.

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

* **Refactor**
* Route parameter and search handling now use in-place updates to reduce
allocations and streamline iteration/control flow; behavior and public
API remain unchanged.
* **Tests**
* Updated tests to capture cloned parameter objects and assert on exact
values rather than relying on mock call history, preventing
mutation-related flakiness.
<!-- end of auto-generated comment: release notes by coderabbit.ai -->

---------

Co-authored-by: autofix-ci[bot] <114827586+autofix-ci[bot]@users.noreply.github.com>
2025-08-17 18:35:45 +02:00
Tanner Linsley
b953a37860 release: v1.131.23 v1.131.23 2025-08-17 16:32:35 +00:00
Flo
9437fee5c7
refactor(router-core,react-router,solid-router): avoid copying arrays just to .reverse() them (#4980)
The pattern of copying an array just to `.reverse()` it and iterate it
from the end ends up creating a transient object (a copy of the array)
that needs to be garbage collected.

For example:
```ts
[...array].reverse().find(() => {/*...*/})
```
or
```ts
[...array].reverse().forEach(() => {/*...*/})
```

Instead we can use a regular `for` loop to iterate it from the end. This
will be mostly beneficial in `router-core > router > buildLocation` that
gets called pretty often.

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

- **Refactor**
- Improved head metadata processing in React and Solid routers to be
more efficient and readable, reducing work for large route metadata
sets.
- Simplified route matching logic to consistently pick the last relevant
match, improving clarity and maintainability.

- **Chores**
- Added a utility to locate the last list item meeting a condition,
supporting cleaner routing internals.
<!-- end of auto-generated comment: release notes by coderabbit.ai -->

---------

Co-authored-by: autofix-ci[bot] <114827586+autofix-ci[bot]@users.noreply.github.com>
2025-08-17 18:30:59 +02:00
Tanner Linsley
72b65cfcca release: v1.131.22 v1.131.22 2025-08-16 19:08:03 +00:00
Flo
d00b9c1678
refactor(router-core): fewer getMatch calls (#4971)
some miscellaneous minor optimizations in the `loadMatches` pipeline.
- try and reduce the number of times we call `getMatch`
- ~~`onReady` doesn't need to return a promise (because it's never used
as such)~~
actually some things fail without the artificially added microtask here
- don't create `beforeLoadPromise` if there is no `beforeLoad` option
anyway

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

- Bug Fixes
- Improved NotFound and error handling to prevent unnecessary blocking
and ensure readiness triggers correctly.
  - More reliable SSR and preload behavior across route transitions.

- Refactor
- Streamlined route loading with per-route stale-while-revalidate,
reducing redundant work and improving navigation responsiveness.
- Reduced internal lookups and clarified readiness semantics for more
predictable loading states.

- Public API
- onReady callback is now synchronous (no Promise), aligning with
updated readiness flow.
<!-- end of auto-generated comment: release notes by coderabbit.ai -->

---------

Co-authored-by: autofix-ci[bot] <114827586+autofix-ci[bot]@users.noreply.github.com>
2025-08-16 21:06:22 +02:00
Tanner Linsley
cb6d34aa95 release: v1.131.21 v1.131.21 2025-08-16 17:42:54 +00:00
Flo
dbf89e5446
refactor(router-core): split loadMatches into its own file (#4969)
After the "flattening" PR https://github.com/TanStack/router/pull/4961,
we now have a very clear *separate responsibility* the `Router` class is
handling: loading matches.

This PR proposes we split the code that handles "loading matches" into
its own `load-matches.ts` file, with the entry points being
- `loadMatches`
- `loadRouteChunk`

In future PRs, we might consider splitting other responsibilities out of
the 3k LoC `router.ts` file

---------

Co-authored-by: autofix-ci[bot] <114827586+autofix-ci[bot]@users.noreply.github.com>
2025-08-16 19:37:14 +02:00
Tanner Linsley
5c59e429a8 release: v1.131.20 v1.131.20 2025-08-16 17:29:16 +00:00
Gürkan Sevil
2c24acbd06
fix(solid-router): correctly assign createLazyFileRoute on window (#4956) 2025-08-16 19:15:58 +02:00