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

6,555 commits

Author SHA1 Message Date
Flo
253ff7b4cf
refactor(router-core): improve router.comparePaths regexp performance (#4747)
We can improve perf of this function *that gets called a lot* by not
grouping the entire string, and only removing the trailing slash.

The entire string is returned by `.replace()`, so we don't ned the group
```
> "/foo/bar/".replace(/\/$/, '')
'/foo/bar'
```

Doing so, we get ~6x performance out of it.

```
 ✓  @tanstack/router-core  tests/other.bench.ts > comparePaths 2183ms
     name                       hz     min     max    mean     p75     p99    p995    p999     rme  samples
   · oldComparePaths  1,300,774.12  0.0006  0.8563  0.0008  0.0008  0.0010  0.0010  0.0017  ±0.35%   650388
   · newComparePaths  7,773,004.63  0.0000  0.2112  0.0001  0.0001  0.0002  0.0002  0.0004  ±0.14%  3886503   fastest

 BENCH  Summary

   @tanstack/router-core  newComparePaths - tests/other.bench.ts > comparePaths
    5.98x faster than oldComparePaths
```
2025-07-22 13:15:42 +02:00
Lee
dae8833a46
docs(router): update Router.matchRoutes arguments (#4739) 2025-07-22 12:16:52 +12: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
Tanner Linsley
4f1eed4390 release: v1.129.2 v1.129.2 2025-07-21 21:59:24 +00:00
Lee
af673b84e4
fix(router-core): update MatchRoutesFn signature and proper deprecate old usage (#4730) 2025-07-21 23:49:01 +02:00
Tanner Linsley
24ba0b7bba release: v1.129.1 v1.129.1 2025-07-21 20:36:10 +00:00
Manuel Schiller
748a4be5a0
fix: fix start vite plugin during dev and prod (#4736) 2025-07-21 22:34:41 +02:00
Lukas Steinbrecher
86e0f8f286
docs(router): add guide on automatic code splitting (#4717)
Co-authored-by: SeanCassiere <33615041+SeanCassiere@users.noreply.github.com>
2025-07-21 17:16:09 +12:00
Tanner Linsley
dc5d0241a5 release: v1.129.0 v1.129.0 2025-07-20 23:11:25 +00:00
Manuel Schiller
f9dfb3121f
feat: pass in router instance in client function middleware (#4723)
Co-authored-by: autofix-ci[bot] <114827586+autofix-ci[bot]@users.noreply.github.com>
2025-07-21 01:09:46 +02:00
Manuel Schiller
a1d54c40df
chore: don't run autofix on draft PRs (#4722) 2025-07-20 11:55:33 +02:00
Tanner Linsley
da6070c820 release: v1.128.8 v1.128.8 2025-07-20 05:39:51 +00:00
Lee
e63f4e49d3
fix(router-core): change error type in ErrorComponentProps (#4691)
fixes #4686

---------

Signed-off-by: leesb971204 <leesb971204@gmail.com>
2025-07-20 07:33:04 +02:00
Tanner Linsley
da3c81c332 release: v1.128.7 v1.128.7 2025-07-20 05:21:56 +00:00
Manuel Schiller
ddc6b5d229
fix: re-enable fuzzy matching to allow notFoundMode: fuzzy (#4721)
fixes #4712
2025-07-20 07:20:28 +02:00
Tanner Linsley
f5e3a5ff94
docs: Correct optional params docs syntax (#4720)
Correct optional parameter syntax in documentation by removing
unnecessary parentheses.

---

**Open Background Agent:** 


[Web](https://www.cursor.com/agents?id=bc-e64937de-18eb-4b0c-8696-c1e1f2eb8a9d)
·
[Cursor](https://cursor.com/background-agent?bcId=bc-e64937de-18eb-4b0c-8696-c1e1f2eb8a9d)

---------

Co-authored-by: Cursor Agent <cursoragent@cursor.com>
2025-07-19 15:32:02 -06:00
Tanner Linsley
1591405bd1 release: v1.128.6 v1.128.6 2025-07-19 15:56:28 +00:00
Manuel Schiller
7ae6f51dd2
fix: ensure unique match id when optional parameter is not present (#4716) 2025-07-19 17:55:03 +02:00
Flo
eeb082457c
feat(router-core) path: parsePathname uses integers for Segment type (#4711)
Using integers instead of strings when possible is always better for
performance. It uses less memory, and enables faster comparisons.

This is also preparatory work for a build-time `parsePathname` as it
will result in a smaller output (though once gzipped it might not make a
difference in downloaded kB in the end).
2025-07-19 13:30:59 +02:00
Flo
113bf2130c
feat(router-core) path: parsePathname returns a readonly array (#4705)
`parsePathname` should return a `ReadonlyArray` instead of `Array`, and
`Segment` should be `readonly` too. This is because if we want to
improve perf by either caching at runtime or pre-computing routes at
build time, we need to ensure those objects can't be manipulated.

An unrelated change in this PR is also to move some inline functions to
module-scoped functions: `segmentToString` (from `resolvePath`) and
`isMatch` (from `matchByPath`). Those functions are in the hot path so
it's nice if the runtime compiler can promote them to optimized
functions.

---------

Co-authored-by: autofix-ci[bot] <114827586+autofix-ci[bot]@users.noreply.github.com>
2025-07-19 10:13:03 +02:00
Tanner Linsley
614ac9bc09 release: v1.128.5 v1.128.5 2025-07-18 23:51:30 +00:00
Manuel Schiller
241a250f58
fix: dev server improvements (#4706) 2025-07-19 01:50:06 +02:00
Tanner Linsley
12a30c5d1f
docs: Identify top 10 how-to docs, add deployment guide (#4701)
<!-- One very short sentence on the WHAT and WHY of the PR. E.g. "Remove
pathHash attribute because it is confirmed unused." or "Add DNS round
robin to improve load distribution." -->
Add a comprehensive how-to guide for deploying TanStack Router to
production and establish a multi-PR process for future documentation.

---------

Co-authored-by: Cursor Agent <cursoragent@cursor.com>
Co-authored-by: autofix-ci[bot] <114827586+autofix-ci[bot]@users.noreply.github.com>
2025-07-18 15:15:07 -06:00
Tanner Linsley
fcba1347e8 release: v1.128.4 v1.128.4 2025-07-18 20:32:28 +00:00
Arciom Picikin
a9270d3c12
fix(react-router): preserve ref type in createLink with required interface properties (#4674)
Fixes #4673

I a bit simplified the `UseLinkReactProps` to make more use of typing
from React (and this simplification just fixes the bug)
Also added a test to check that the bug is no longer reproduced
2025-07-18 22:25:22 +02:00
Tanner Linsley
33302b6cda
docs: Create TanStack Router installation how-to (#4700)
Add new 'How-To' documentation section for React with a terse
installation guide to provide bite-sized, task-oriented instructions.

This new section aims to provide extremely concise, step-by-step
instructions for common tasks, making it easier for users and AI to
quickly find and follow specific procedures. Existing guides that
previously contained detailed installation steps now reference this new,
focused how-to guide to avoid content duplication and improve
discoverability.

---------

Co-authored-by: Cursor Agent <cursoragent@cursor.com>
Co-authored-by: autofix-ci[bot] <114827586+autofix-ci[bot]@users.noreply.github.com>
2025-07-18 13:41:21 -06:00
Tanner Linsley
3b8b2bc24a
docs: Document optional path params for i18n (#4699)
Add documentation for prefix-based internationalization (i18n) using
Optional Path Parameters.

This PR adds a comprehensive guide on implementing i18n patterns,
covering:
- Prefix-based i18n routing (e.g., `/{-$locale}/about`)
- Complex i18n patterns with multiple optional parameters
- Language navigation using function-style `params` for `Link`
components
- Advanced i18n with route groups
- SEO best practices (canonical URLs, hreflang)
- Type safety for locale validation

---------

Co-authored-by: Cursor Agent <cursoragent@cursor.com>
Co-authored-by: autofix-ci[bot] <114827586+autofix-ci[bot]@users.noreply.github.com>
2025-07-18 13:40:12 -06:00
Manuel Schiller
5b2dd557fe
fix: during route ranking, rank params higher if followed by a static segment (#4685)
fixes #4681
2025-07-18 10:49:42 -06:00
Tanner Linsley
9d9554c43f release: v1.128.3 v1.128.3 2025-07-17 22:38:48 +00:00
Sean Cassiere
6ed0caf0a5
docs(router): prefixes and suffixes for path params (#4690) 2025-07-18 10:34:32 +12:00
wookhyung
7c6d4c1325
fix(router-core): reset statusCode to 200 on navigation start (#4664)
Co-authored-by: autofix-ci[bot] <114827586+autofix-ci[bot]@users.noreply.github.com>
2025-07-18 00:25:35 +02:00
Tanner Linsley
80e76377b5 release: v1.128.2 v1.128.2 2025-07-17 22:13:43 +00:00
Manuel Schiller
1b319d0485
fix: default to addHmr in dev if not set (#4689) 2025-07-18 00:12:11 +02:00
Nico Lynzaad
e90171ab38
fix: resolve flaky e2e tests on useServerFn redirect tests (#4688)
This PR addresses some flaky tests in the redirect e2e tests for
react-start and solid start.

Specifically, when testing external redirects use useServerFn it was
trying to reach out to http://example.com. This updates it to redirect
to the local dummy server.
2025-07-18 00:02:28 +02:00
Usman S. (Max Programming)
132bd0c6d3
docs(start): build-from-scratch guide to use customVite(React/Solid)Plugin (#4678)
Co-authored-by: Sean Cassiere <33615041+SeanCassiere@users.noreply.github.com>
2025-07-17 23:00:02 +12:00
Tanner Linsley
4704c97779 release: v1.128.1 v1.128.1 2025-07-17 07:34:51 +00:00
wookhyung
1930152cca
fix(start-server-core): properly merge middleware context objects (#4665) 2025-07-17 19:29:51 +12:00
Flo
89c7b5d660
test(react-router,solid-router): test re-render for preload='viewport' (#4672) 2025-07-17 19:15:11 +12: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
Tanner Linsley
b3a83c186f release: v1.128.0 v1.128.0 2025-07-16 19:49:23 +00:00
Tanner Linsley
a2424c0f02
feat: optional path params (#4597)
Co-authored-by: Sean Cassiere <33615041+SeanCassiere@users.noreply.github.com>
Co-authored-by: Manuel Schiller <manuel.schiller@caligano.de>
Co-authored-by: Indrek Ardel <indrek@ardel.eu>
Co-authored-by: autofix-ci[bot] <114827586+autofix-ci[bot]@users.noreply.github.com>
2025-07-16 13:41:58 -06:00
Indrek Ardel
db1331f9b8
tests(solid-router): enable ClientOnly SSR test (#4666) 2025-07-16 19:58:35 +02:00
Flo
a719495cd8
fix(react-router) useLinkProps memoization and performance (#4668)
Co-authored-by: autofix-ci[bot] <114827586+autofix-ci[bot]@users.noreply.github.com>
2025-07-16 19:45:45 +02:00
Tanner Linsley
4f71f6b398 release: v1.127.9 v1.127.9 2025-07-15 20:26:47 +00:00
Indrek Ardel
ba590c2111
fix(solid-router): prevent client effects running on server (#4621) 2025-07-15 22:19:37 +02:00
Sean Cassiere
aa1fb5d553
fix(router-plugin): composed plugin to consider options from json config (#4654) 2025-07-15 14:18:02 +12:00
Tanner Linsley
51307bb47b release: v1.127.8 v1.127.8 2025-07-14 21:14:10 +00:00
Manuel Schiller
41bf26b409
fix: allow createRouter to be async (#4652) 2025-07-14 23:12:36 +02:00
Ahmed Abdelbaset
1746c08918
docs(start): remove todo from Server Routes guide (#4650) 2025-07-14 22:43:26 +12:00
Tanner Linsley
5ecdd87fd2 release: v1.127.7 v1.127.7 2025-07-13 20:51:26 +00:00