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

35 commits

Author SHA1 Message Date
Nico Lynzaad
915de641cd
refactor(router-core): more stable url decoding (#5663)
* add decode path segment util

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

* add e2e tests

* add test recommendations

* nitpick

* minor enhancements

* build array once

* add additional unit and e2e tests

* remove react import from solid test

* nitpicks

* final nitpicks

* use history.push
2025-10-28 23:33:50 +02:00
Nico Lynzaad
d293e1b15a
fix(route-core, router-generator): resolve non-nested routes correctly in generator (#5402)
* revert router-core changes

* add experimental nonnested path changes to generator

* update router-generator unit tests

* update basic-file-based-e2e

* cleanup

* cleanup

* add tests for isValidNonNestedPaths

* resolve eslint issues

* align naming to documentation

* cleanup

* update solidjs basic-file-based tests

* update documentation

* ci: apply automated fixes

* resolve test issues

* code rabbit suggestions

* ci: apply automated fixes

* fix excess period in routeTree path

* restore snapshot again

* ci: apply automated fixes

* resolve nitpick

* resolve removeTrailingUnderscore issue

* fix routeTree path

* final nitpicks

* better test description

* exclude snapshots from prettier

* minor cleanup

* resolve change in snapshots due to changes from main

* update prettierignore

---------

Co-authored-by: autofix-ci[bot] <114827586+autofix-ci[bot]@users.noreply.github.com>
2025-10-24 10:29:24 +02:00
Nico Lynzaad
4b0004cfbb
test(e2e-Utils): export built package from e2eUtils (#5336)
* add build step and update exports

* address flaky test

* export types

* ci: apply automated fixes

* use vite for building

* ci: apply automated fixes

* code rabbit issues

---------

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

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

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

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

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

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

- New Features
- Added non-nested route demos (named, prefix, suffix, path) with
index/foo/bar pages and updated navigation in React and Solid examples.
- Bug Fixes
- Improved path parsing/matching to handle non-nested segments,
prefixes/suffixes and trailing underscores; refined route
sorting/resolution.
- Tests
- Added comprehensive E2E coverage for non-nested paths; removed
obsolete baz-based tests.
- Expanded unit tests for path interpolation and matching (underscore,
prefix/suffix cases).
<!-- end of auto-generated comment: release notes by coderabbit.ai -->
2025-09-22 03:12:27 +02:00
Nico Lynzaad
cf2346ba42
fix(router-core): Non-nested paths (#5169)
This PR continues on from #5165 and primarily adds additional tests to
path resolution and matchByPath for non-nested paths in additiona to e2e
test for both react and solid router to verify non-nesting
functionality.

One additional issue was picked up for handling of normal path segments.

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

- New Features
- Added non-nested demo routes and navigation examples (including
dynamic and edit paths) for React and Solid, with headings, links, and
parameter displays.
- Bug Fixes
- Improved path parsing/decoding for non-nested segments to prevent
unintended nesting and ensure correct parameter values.
- Tests
- Added broad unit tests for non-nested path parsing/matching/resolution
(case-sensitive/insensitive, wildcards, optional/fuzzy).
- Added e2e tests validating non-nested navigation and params; reduced
e2e flakiness by awaiting network idle.
<!-- end of auto-generated comment: release notes by coderabbit.ai -->
2025-09-19 01:05:26 +02:00
Nico Lynzaad
ab12c06634
fix(router-core): parse non-nested path params correctly (#5165)
When parsing path params to interpolate the path non-nested path params
```/path/$param_``` was being parsed in the same manner as regular path
params ```/path/$param```.

This PR adds consideration for the trailing underscore when parsing the
path for non-nested path params as well as unit tests on path
interpolation and e2e tests for useParams to ensure this is parsed
correctly and updates correctly when params change.

This resolves #5164

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

- New Features
- Support trailing-underscore non-nested path params (e.g., /users/$id_
→ /users/123).
- UI shows an additional navigation link for the non-nested route
(/params-ps/non-nested/foo2/bar2) and improved link display text.

- Tests
- Expanded React and Solid e2e tests to cover the new link, navigation,
and param parsing for foo2/bar2.
- Added unit tests validating interpolation/matching for the $param_
syntax.
<!-- end of auto-generated comment: release notes by coderabbit.ai -->
2025-09-18 20:28:01 +02: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
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
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
Brenley Dueck
e86dfea947
fix: remount deps for solid (#4947) 2025-08-13 22:41:56 +02:00
Nico Lynzaad
f0a60cbb71
test(e2e): use locally hosted api over an external provider (#4725)
A lot of our e2e tests are querying external endpoints like
[typicode.com](https://jsonplaceholder.typicode.com) or
[example.com](https://example.com)

This is not ideal as it makes the e2e tests beholden to external factors
for example unavailability or rate limiting of these endpoints.

This PR addresses this by starting and stopping a local dummy server for
each test that needs to query external endpoints and mocks the results.
The setup and teardown have been implemented on each test package
individually so as to allow custom requirements where needed.

---------

Co-authored-by: Sean Cassiere <33615041+SeanCassiere@users.noreply.github.com>
2025-07-22 00:15:28 +02:00
Nico Lynzaad
3854370bdf
fix: assign random ports for e2e tests (#4676)
This is a follow on from #4653

This PR resolves flaky E2E tests caused by port collisions when running
tests in parallel.

Instead of deriving ports from package names (which can collide), this
new approach assigns a random, available port to each test server
instance.

Key Changes:

- Random Port Allocation: Each test server (Playwright, dummy servers)
gets a unique, random port at startup.
- File-based Sync: The server writes its assigned port to a port.txt
file in its test project directory, this is kept unique through using
the package name or another input string for the file name.
- Test Runner Sync: The test runner reads the port from that file to
build the correct URL.
- Automatic Cleanup: All port files are deleted at the start of each
test:e2e run to ensure fresh ports.

Local parallel runs (up to 10) have shown this to be stable and free of
collisions.

---------

Co-authored-by: autofix-ci[bot] <114827586+autofix-ci[bot]@users.noreply.github.com>
2025-07-17 07:24:59 +02:00
wookhyung
f9b5a5a4a8
fix(start): support SSR for non-Latin character route paths (#4611) 2025-07-10 15:33:18 +12:00
Brenley Dueck
1098db7c88
fix(solid-router): rerender match when id changes (#4568) 2025-07-06 10:12:17 +02:00
Manuel Schiller
5cacc14b13
fix: if validate search rewrites search params, issue a server-side redirect (#4439)
Co-authored-by: autofix-ci[bot] <114827586+autofix-ci[bot]@users.noreply.github.com>
2025-06-16 19:57:42 +02:00
Manuel Schiller
8b5accb27c
feat: Merge alpha to main (#4365)
Co-authored-by: Tanner Linsley <tannerlinsley@gmail.com>
Co-authored-by: Tanner Linsley <tannerlinsley@users.noreply.github.com>
Co-authored-by: Iha Shin (신의하) <me@xiniha.dev>
Co-authored-by: Sean Cassiere <33615041+SeanCassiere@users.noreply.github.com>
Co-authored-by: MoeedDar <moeed.dar@gmail.com>
Co-authored-by: autofix-ci[bot] <114827586+autofix-ci[bot]@users.noreply.github.com>
Co-authored-by: Saša Šijak <me@ssijak.com>
Co-authored-by: Christopher Horobin <chrishorobin@hotmail.com>
Co-authored-by: Ryan Gillie <gillie.ryan@hotmail.com>
Co-authored-by: Jaga Santagostino <jagasantagostino@gmail.com>
Co-authored-by: Birk Skyum <birk.skyum@pm.me>
Co-authored-by: Yeoh Joer <yeoh.joer@outlook.com>
Co-authored-by: Dane Grant <danecando@gmail.com>
Co-authored-by: Birk Skyum <74932975+birkskyum@users.noreply.github.com>
Co-authored-by: Luis Merino <mail@luismerino.name>
Co-authored-by: ThaumRystra <9525416+ThaumRystra@users.noreply.github.com>
Co-authored-by: Adam Hunter <arhunter@gmail.com>
Co-authored-by: Leonardo Montini <lion.48m@gmail.com>
Co-authored-by: Joel Tannas <jtannas@gmail.com>
Co-authored-by: scarf <greenscarf005@gmail.com>
Co-authored-by: Lenz Weber-Tronic <lorenz.weber-tronic@apollographql.com>
Co-authored-by: Iñaki Larramendi <30437204+ilarramendi@users.noreply.github.com>
Co-authored-by: Hiển Đào Vinh <neo.go.vn@gmail.com>
Co-authored-by: Lleyton W Morris <42259073+ViewableGravy@users.noreply.github.com>
Co-authored-by: Lleyton Morris <lmorris@nexigen.digital>
Co-authored-by: Matthew Struble <matt@vevox.io>
Co-authored-by: Matt Anderson <matt@mattdev.ca>
Co-authored-by: Chung <chungwong@users.noreply.github.com>
Co-authored-by: Maxx Coffee <josh@joshcoffee.dev>
Co-authored-by: Joshua Coffee <joshcoffee@gannett.com>
Co-authored-by: Jack Herrington <jherr@pobox.com>
Co-authored-by: Neeraj Dalal <admin@nrjdalal.com>
Co-authored-by: Thomas Marnet <thomas.marnet@gmail.com>
Co-authored-by: Vianney Carel <vcarel@users.noreply.github.com>
Co-authored-by: Vianney Carel <vianney.carel@logfuse.fr>
Co-authored-by: Diego Rincón <97266392+diegoarff@users.noreply.github.com>
Co-authored-by: Erfan Hosseini <43422324+Erfanhosseini98@users.noreply.github.com>
Co-authored-by: IderAghbal <3328396+IderAghbal@users.noreply.github.com>
Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
Co-authored-by: Andrew Jefferson <8148776+eastlondoner@users.noreply.github.com>
2025-06-10 23:19:32 +02:00
Birk Skyum
eb21d01ea1
test(react-router) should update title on navigation (#3610)
when client navigating, the react-router doesn't update the head meta
tags, such as the title

---------

Co-authored-by: Manuel Schiller <manuel.schiller@caligano.de>
2025-03-02 22:56:22 +01:00
Lee
4d35542f98
fix(router-core): allow %25 in path params (#3419)
fixes #3402

---------

Signed-off-by: leesb971204 <leesb971204@gmail.com>
Co-authored-by: Sean Cassiere <33615041+SeanCassiere@users.noreply.github.com>
2025-02-25 11:13:27 +13:00
Manuel Schiller
648b133fe8
tests: stabilize e2e tests to not be dependent on external host (#3302)
Co-authored-by: autofix-ci[bot] <114827586+autofix-ci[bot]@users.noreply.github.com>
2025-02-01 11:13:10 +01:00
Manuel Schiller
3f1f24f9ef
tests: create shared, non-published package for e2e utils (#3296) 2025-01-31 23:49:07 +01:00
Manuel Schiller
8442ef505c
tests: notFound handling in notFound when SSRing (#3283) 2025-01-30 23:18:58 +01:00
Tom Rehnström
366848eb0e
feat(react-router): add useCanGoBack (#3017)
also fixes that history does not notify twice for certain actions
2025-01-03 21:09:58 +01:00
Manuel Schiller
224a261ab0
fix(react-router): properly handle redirects when thrown during parallel preload (#3103)
fixes #3097
2025-01-03 03:02:44 +01:00
Tom Rehnström
f420670bf2
feat(react-router): update useBlocker hook to provide current and next location when conditionally blocking (#1790)
* chore: clean up changes

* feat: clean up work and address feedback

* feat: add backwards compat

* ci: apply automated fixes

* feat: give history action to subscribers via notify

* fix: provide go index to history subscribers

* docs: updated docs accourding to feedback

* fix: changed valid notify call

* rename to `type`

* remove non existing `pushstate`event

* cleanup

* typesafe API for shouldBlockFn

* feat: added blocking state to resolver and updated examples

* docs: updated useBlocker and navigation-blocking docs

* test: added type tests to blocker and changed type implementation of blocker

* test: added better unit tests for useBlocker hook

* test: added e2e tests for blocker and legacy blocker

* wip: stash files before merge

* fix: unstashed e2e file after merge

* fix lockfile

* docs

* typesafety for `<Block>`

* always return resolver to not break backwards compatibility

* fix: removed zod from navigation blocking example to fix build problem

* chore: update lock file

* finishing touches

* ci: apply automated fixes

---------

Co-authored-by: autofix-ci[bot] <114827586+autofix-ci[bot]@users.noreply.github.com>
Co-authored-by: Manuel Schiller <manuel.schiller@caligano.de>
2024-12-15 10:32:16 +01:00
Josh Slate
92147140c8
feat(react-router): implement hash change "Scroll Into View" option (#2996)
* feat: implement hash change scrollIntoView option

* e2e tests for hash change scroll behavior

* update e2e tests to use data-testId

* address feedback

* remove accidental change to package.json

* add anchor link to example navigation

* ci: apply automated fixes

* handle when location transitions without commitLocation running

---------

Co-authored-by: autofix-ci[bot] <114827586+autofix-ci[bot]@users.noreply.github.com>
2024-12-14 08:58:03 +01:00
Manuel Schiller
5ad95cf3f7
feat(react-router): allow to redirect to external targets, add reloadDocument option (#3004)
* feat(react-router): allow to redirect to external targets, add `reloadDocument` option

* ci: apply automated fixes

---------

Co-authored-by: autofix-ci[bot] <114827586+autofix-ci[bot]@users.noreply.github.com>
2024-12-13 12:29:33 +01:00
Manuel Schiller
ef4a9498c0
fix: upgrade to vinxi 0.5 and vite 6 (#2923)
Co-authored-by: autofix-ci[bot] <114827586+autofix-ci[bot]@users.noreply.github.com>
Co-authored-by: SeanCassiere <33615041+SeanCassiere@users.noreply.github.com>
2024-12-06 00:36:10 +01:00
Sean Cassiere
c7403a3c19
test(e2e): retrofit all e2e sandboxes tests to use open ports (#2914) 2024-12-04 11:11:57 +13:00
Manuel Schiller
0873c1f0c9
feat(react-router): add support for structural sharing for finegrained selectors (#2647)
Co-authored-by: chorobin <chrishorobin@hotmail.com>
2024-11-09 22:41:12 +01:00
Manuel Schiller
5499693bb3
fix(react-router): correct typing for unnested routes (#2597)
* fix(react-router): correct typing for unnested routes

fixes #2595
fixes #2596

* regenerate examples/tests
2024-10-20 17:48:18 +02:00
Manuel Schiller
0abdb16233
fix(router-generator): correctly generate ids for single routes inside route groups (#2585) 2024-10-19 01:08:16 +02:00
Manuel Schiller
4e07c749c1
tests: add e2e test for getRouteApi inside route groups (#2569) 2024-10-18 00:31:21 +02:00
Manuel Schiller
8c7f14b15b
fix: correctly handle route groups (#2550)
* fix: correctly handle route groups

do not remove route groups from ids as we need them to ensure uniqueness of ids at runtime.

fixes #2501



---------

Co-authored-by: autofix-ci[bot] <114827586+autofix-ci[bot]@users.noreply.github.com>
2024-10-15 21:31:38 +02:00
Sean Cassiere
a9017a9a7a
chore: copying e2e test sandboxes from examples/ to e2e/ (#2357) 2024-09-18 18:09:22 +02:00