0
Fork 0
mirror of https://github.com/TanStack/router.git synced 2026-11-18 19:34:24 +00:00
Commit graph

6,634 commits

Author SHA1 Message Date
Tanner Linsley
a286e6becb release: v1.131.42 v1.131.42 2025-09-12 11:21:42 +00:00
Sean Cassiere
081b949d99
fix(router-devtools-core): add copy to clipboard for search params object (#5140) 2025-09-12 23:18:29 +12:00
Tanner Linsley
ca84fb05f3 release: v1.131.41 v1.131.41 2025-09-11 21:29:10 +00:00
Nico Lynzaad
2b6789baa6
fix(router-core): _strictParams and path defining characters (#5135)
This PR resolves #5133 by making the _strictParams more conscious of
path defining characters and other wildcards. It also adds e2e tests for
react and solid

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

- **New Features**
- Added “Non-nested path params” pages and links in React and Solid
basic-file-based e2e tests at /params-ps/non-nested, plus nested dynamic
routes to view single and combined params; UI links and outlets
included.

- **Bug Fixes**
- Improved internal path-parameter resolution so strict param extraction
uses the full route path for more accurate matching.

- **Tests**
- Added end-to-end tests verifying navigation to
/params-ps/non-nested/foo/bar and correct partial vs. full param values.
<!-- end of auto-generated comment: release notes by coderabbit.ai -->
2025-09-11 23:27:28 +02:00
Tanner Linsley
a60022301c release: v1.131.40 v1.131.40 2025-09-11 16:59:03 +00:00
Flo
d681a0cf66
refactor(router-core): processRouteTree sorting uses constants for all score modifiers (#5131)
Just to make it easier to tweak the values and understand the scales /
functions, we extract all score modifiers to constants w/ descriptive
names.

This PR is a no-op, no logic was modified.

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

## Summary by CodeRabbit

- Bug Fixes
- Improved route matching accuracy by prioritizing routes with static
segments that appear after dynamic parameters.
- More predictable matching in complex paths; reduces unexpected
selections.
  - Wildcard routes handled more consistently.

- Refactor
- Updated internal route scoring to consider deeper static segments
without changing the public API.

<!-- 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-09-11 18:57:29 +02:00
Tanner Linsley
5d6cb80fd7 release: v1.131.39 v1.131.39 2025-09-11 16:34:03 +00:00
Flo
65c07d7e99
refactor(router-core): processRouteTree in its own file (#5128)
- move `processRouteTree` to a separate file because the logic is very
self-contained
- create a new function `sortRoutes` w/ the sorting logic, so it can be
tested independently

This PR is a no-op, we're just moving code around, *nothing* was
changed.

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

## Summary by CodeRabbit

- New Features
- Added a public Route type for describing route objects in route trees.

- Refactor
- Consolidated route processing into a dedicated module for clearer
separation and maintainability.
- Updated public exports for route processing; existing imports may need
to be adjusted.
  - No runtime behavior changes expected.

- Tests
- Updated tests to use the new public Route type and revised import
paths.

<!-- 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-09-11 18:32:17 +02:00
Tanner Linsley
e2167659cd release: v1.131.38 v1.131.38 2025-09-11 15:09:09 +00:00
Nico Lynzaad
b6a98805cc
fix(router-core): params.parse should run as minimally as possible (#5124)
resolves #5123 and adds checks to tests to ensure this runs as minimally
as possible

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

* **Performance**
* Reuses existing route matches to reduce redundant param parsing and
stabilize navigation/loading behavior.
* **Tests**
* Updated tests to match the new postId param shape, navigation paths,
and parameter displays; added mocks to verify param parsing calls.
<!-- end of auto-generated comment: release notes by coderabbit.ai -->
2025-09-11 17:07:28 +02:00
Tanner Linsley
9a86563ae0 release: v1.131.37 v1.131.37 2025-09-11 07:29:36 +00:00
Nico Lynzaad
8f8f03fbdc
fix(router-core): parse _strictParams. (#5120)
with changing useParams to make use of _strictParams it became apparent
that _strictParams did not apply param parsing correctly. This PR
resolves that problem and hence useParams now return the parsed params
correctly.

This PR also adds unit tests in both react-router and solid-router to
test this expected result.

A separate PR has been created to merge into alpha (#5121)

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

## Summary by CodeRabbit

- New Features
- Stricter route parameter parsing and validation with support for
custom parse/stringify.
- Clearer per-route parameter error reporting, with optional
throw-on-error behavior.
  - More consistent parameter values across nested routes and loaders.

- Tests
- Added integration tests validating useParams with nested routing,
custom param parsing/stringifying, and loader data in both React and
Solid routers.

<!-- end of auto-generated comment: release notes by coderabbit.ai -->
2025-09-11 09:27:55 +02:00
Robert Soriano
6167c0c60d
chore(examples): Update Clerk server handler usage (#5026)
Co-authored-by: autofix-ci[bot] <114827586+autofix-ci[bot]@users.noreply.github.com>
2025-09-10 19:33:13 +02:00
Nico Lynzaad
834128ea84
docs: Integration with Esbuild - update title to reflect "Esbuild" (#5112)
The integration with Esbuild page's title is reflecting as Vite.

This PR updates it to reflect as "Esbuild"
2025-09-09 14:34:01 +02:00
Nico Lynzaad
a0e4641728
docs: resolve invalid relative paths (#5111)
paths in "migrate from react location" and "migrate from react-router"
to the installation docs form installing Tanstack router returns 404.

This PR fixes the incorrect relative paths.

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

## Summary by CodeRabbit

* **Documentation**
* Updated installation guide links in the React migration guides for
TanStack Router to point to the correct “How to Install” page.
* Ensures migration steps reference the right documentation, improving
navigation for users following the guides.
  * No functional or code changes.

<!-- end of auto-generated comment: release notes by coderabbit.ai -->
2025-09-09 14:30:57 +02:00
Kilian Finger
d939463e93
docs: fix external data loading path (#5109)
The link to External Data Loading on the [Query
Integration](https://tanstack.com/router/latest/docs/integrations/query)
page currently throws a 404.

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

## Summary by CodeRabbit

* **Documentation**
* Corrected a link in the Router integrations guide to point to the
proper External Data Loading page in the React framework section. This
fixes navigation from that note and ensures readers can access the
referenced guidance without errors. No functional changes to the
product; content remains otherwise unchanged and reduces confusion.

<!-- end of auto-generated comment: release notes by coderabbit.ai -->
2025-09-09 13:32:06 +02:00
Tanner Linsley
99d9044657 release: v1.131.36 v1.131.36 2025-09-08 04:22:24 +00:00
Nico Lynzaad
907b1f7ce9
fix: release (#5104)
release

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

## Summary by CodeRabbit

* **Documentation**
* Minor punctuation update in inline documentation comments to maintain
consistency.
  * No changes to features, user interface, performance, or behavior.
  * APIs, configuration, and compatibility remain unaffected.
* This update is purely editorial and does not alter builds,
deployments, or runtime.
  * Users and integrators do not need to take any action.

<!-- end of auto-generated comment: release notes by coderabbit.ai -->
2025-09-08 06:20:54 +02:00
Nico Lynzaad
22c9888857
fix(react-router, solid-router) - useParams should only be concerned about the relevant params (#5097)
#5020 highlighted an issue where when using useParams in parent route
(that has its own path param) with child routes that also use path
params this can cause excessive re-rendering of the parent route when
the params for the child routes changes.

The root cause for this is that the child params are available to the
parent route, even when strict=false was not specified and this also
does not match to the types that is being returned in this case. This
can be worked around by using select inside the useParams hook/function
but results in unnecessary boilerplate.

This PR attempts to resolve the issue by dealing with the two distinct
cases, one where we are only concerned about the path params of the
current route and prior routes (strict=true/undefined) and the second
where we want access in the parent route to the path params of the child
routes (strict=false).

In the strict case we use the match id to return the params of the
specific match, which is constant and results in stable rendering, while
in the strict=false case we fallback to the initial implementation of
returning params from the useMatch result which can be variable and
requires re-rendering to be done.

Changes were done on useParams for both react and solid, in solid's case
this wasn't causing re-renders but did return unexpected child params,
the change for solid is more toward keeping the API and expected outputs
consistent between the two frameworks. existing unit tests for react was
updated and e2e tests for both frameworks was added to ensure rendering
and results match the expected.

A separate merge has been prepared for Alpha and will be merged on
signoff of this one.

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

- **New Features**
- Added nested named-parameter routes (three-level: foo → bar → baz) in
example apps with nested navigation, outlets, links and render-count
displays.
- Added a small render-counter component to visualize component
re-renders.

- **Bug Fixes**
- Improved params selection to respect strict vs non-strict modes,
reducing excess renders and producing stable param values.

- **Tests**
- Added E2E tests for React and Solid examples covering param navigation
and render-counts; expanded router unit tests for nested-route stability
and remount behavior.
<!-- end of auto-generated comment: release notes by coderabbit.ai -->
2025-09-07 11:35:09 +02:00
Jakob Norlin
6202162dd3
docs: change hydration target to document.body in custom client.tsx for Solid (#5091)
Fixes #5085

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

## Summary by CodeRabbit

* **Documentation**
* Updated the Solid framework “Learn the Basics” guide to correct the
client hydration example, targeting the appropriate DOM root.
* Clarifies which element to hydrate, aligning the snippet with current
best practices and reducing confusion for readers.
* Improves copy‑paste reliability of the example for newcomers following
the setup steps.

<!-- end of auto-generated comment: release notes by coderabbit.ai -->
2025-09-05 19:07:19 -05:00
Flo
fbedc50668
test(router-core): add initial tests for router behavior (#4993)
First PR to add framework agnostic unit tests covering router behavior.
We need to add many more (and eventually lighten the tests in each
framework).

This PR adds tests about when a beforeLoad and a loader should execute.

Next PR should add tests about how context is passed.

Look at these issues to see what should be tested:
https://github.com/TanStack/router/issues/4696

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

* **Tests**
* Added comprehensive tests validating preload behavior for route
loading hooks (beforeLoad and loader), covering resolved, pending, and
rejected outcomes including notFound and redirects.
* Verifies navigation control flow, hook invocation counts, pending vs
cached matches, final locations, and loader data handling.
* Includes sibling-route "stay" scenarios and timing helpers to
strengthen async/timing reliability.
<!-- 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-09-05 23:59:13 +02:00
Ian J. MacIntosh
741821b2d2
docs(start): Add Railway instructions (#4910)
I was puzzled why Railway wasn't starting a server, then realized
TanStack Start doesn't define the start command by default
2025-09-04 21:49:49 -05:00
Yağız Yorulmazlar
e83fb3b740
docs: Rename Link Preloading Timeout to Link Preloading Delay (#5082)
The current `Link` component doesn't have `preloadTimeout` prop as
stated in the docs. This PR updates documentation to use the correct
`preloadDelay` prop.

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

## Summary by CodeRabbit

* **Documentation**
* Updated terminology from “Link Preloading Timeout” to “Link Preloading
Delay” to improve clarity.
* Revised examples to use the preloadDelay option instead of
preloadTimeout.
  * Clarified that the default delay remains 50 ms.
* Ensured consistency across headings, descriptions, and code snippets
to match the current public API.

<!-- end of auto-generated comment: release notes by coderabbit.ai -->
2025-09-04 21:24:27 -05:00
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