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

6,483 commits

Author SHA1 Message Date
autofix-ci[bot]
a8ea2b838c
ci: apply automated fixes 2025-07-25 20:20:55 +00:00
Tanner Linsley
ecfe14bc1f
docs: how-to guide for file-based router testing (#4776)
Add a new how-to guide for testing TanStack Router with file-based
routing to cover specific patterns and challenges.

---

[Open in
Web](https://cursor.com/agents?id=bc-ee0f6db1-18b2-4c3b-b69c-13ea7f849190)
• [Open in
Cursor](https://cursor.com/background-agent?bcId=bc-ee0f6db1-18b2-4c3b-b69c-13ea7f849190)

Learn more about [Background
Agents](https://docs.cursor.com/background-agent/web-and-mobile)

---------

Co-authored-by: Cursor Agent <cursoragent@cursor.com>
2025-07-25 14:19:51 -06:00
autofix-ci[bot]
1d34e56792
ci: apply automated fixes 2025-07-25 20:12:00 +00:00
Tanner Linsley
94ec310682
docs: more! (#4775)
Add comprehensive authentication, testing, and debugging how-to guides
to enhance documentation.

---

[Open in
Web](https://cursor.com/agents?id=bc-ea21e97d-685a-451f-9700-6955d86ef170)
• [Open in
Cursor](https://cursor.com/background-agent?bcId=bc-ea21e97d-685a-451f-9700-6955d86ef170)

Learn more about [Background
Agents](https://docs.cursor.com/background-agent/web-and-mobile)

---------

Co-authored-by: Cursor Agent <cursoragent@cursor.com>
2025-07-25 14:10:52 -06:00
autofix-ci[bot]
1cd28688c7
ci: apply automated fixes (attempt 2/3) 2025-07-25 19:16:09 +00:00
autofix-ci[bot]
cb08dd6f6a
ci: apply automated fixes 2025-07-25 19:15:11 +00:00
Tanner Linsley
269625a5a7
docs: Split ui library documentation into guides (#4774)
Split the UI library integration guide into individual how-to guides for
Shadcn/ui, Material-UI, Framer Motion, and Chakra UI.

---

[Open in
Web](https://cursor.com/agents?id=bc-8573175f-c315-4c20-a848-fc2e39ef00eb)
• [Open in
Cursor](https://cursor.com/background-agent?bcId=bc-8573175f-c315-4c20-a848-fc2e39ef00eb)

Learn more about [Background
Agents](https://docs.cursor.com/background-agent/web-and-mobile)

Co-authored-by: Cursor Agent <cursoragent@cursor.com>
2025-07-25 13:14:06 -06:00
autofix-ci[bot]
4c18a66936
ci: apply automated fixes 2025-07-25 19:04:33 +00:00
Tanner Linsley
d7d9d4e8cc
docs: migrate from react router v6
Add a comprehensive migration guide from React Router v7 to TanStack
Router, addressing feedback to target the latest version.

The original PR #4704 aimed to provide a migration guide from React
Router v6. However, a comment from schiller-manuel questioned why v6 was
targeted instead of v7. This PR updates the scope to focus on React
Router v7, which was released in November 2024 and is the current
version, ensuring the guide is relevant for users migrating from the
latest React Router.

---

[Open in
Web](https://cursor.com/agents?id=bc-035967dd-2396-4ba3-9226-f0bfd1c21f11)
• [Open in
Cursor](https://cursor.com/background-agent?bcId=bc-035967dd-2396-4ba3-9226-f0bfd1c21f11)

Learn more about [Background
Agents](https://docs.cursor.com/background-agent/web-and-mobile)

---------

Co-authored-by: Cursor Agent <cursoragent@cursor.com>
2025-07-25 13:03:25 -06:00
autofix-ci[bot]
38073cb5e9
ci: apply automated fixes 2025-07-25 18:51:55 +00:00
Tanner Linsley
2703b7fcf0
docs: how-to SSR guide
Add a comprehensive "How to Set Up Server-Side Rendering (SSR)" guide to
provide practical, step-by-step instructions and address feedback from
PR #4703.

The previous PR #4703 aimed to add an SSR setup guide but had concerns
regarding overlap with an existing conceptual SSR guide and specific
technical implementation details (e.g., streaming SSR, Vite config).
This PR addresses those concerns by creating a distinct, practical
"how-to" guide with complete code examples, troubleshooting, and a clear
recommendation for TanStack Start, while ensuring it complements the
existing theoretical guide.

---

[Open in
Web](https://cursor.com/agents?id=bc-8555f196-638f-4bec-90a4-5eac52b5918a)
• [Open in
Cursor](https://cursor.com/background-agent?bcId=bc-8555f196-638f-4bec-90a4-5eac52b5918a)

Learn more about [Background
Agents](https://docs.cursor.com/background-agent/web-and-mobile)

Co-authored-by: Cursor Agent <cursoragent@cursor.com>
2025-07-25 12:50:56 -06:00
Karthik Appiah
b38c42e753
docs(start): add missing dev dep to build-from-scratch guide (#4758) 2025-07-25 09:07:35 +12:00
SeanCassiere
6a89d3c048
chore(root): fix missing speakeasy logo 2025-07-24 10:17:14 +12:00
Manuel Schiller
3b9128e502
docs: slight correction in automatic code splitting 2025-07-23 20:43:30 +02:00
Lee
68fd70bf8e
docs(router): update types for RouteOptions and RouteMatch (#4754)
Closes #3811

---------

Signed-off-by: leesb971204 <leesb971204@gmail.com>
Co-authored-by: Sean Cassiere <33615041+SeanCassiere@users.noreply.github.com>
2025-07-23 23:41:22 +12:00
Flo
58093828f2
test(router-core): add unit tests for matchByPath (#4749)
This PR is simply adding unit test to the existing `matchByPath`
function.

However, it does highlight some weird cases / bugs:

- this test passes OK, I'm just wondering whether that's a real case
that can happen (in which case the test is good to keep) or if it's just
accidental
  ```ts
expect(matchByPath('/', '/a/1/b/2', { to: '/a/$id/b/$id' })).toEqual({
id: '2' })
  ```

- this test passes OK, I'm just a little surprised that it includes a
`/` char, because *any other* case does not
  ```ts
expect(matchByPath('/', '/a/', { to: '/a/$' })).toEqual({ _splat: '/',
'*': '/' })
  ```

- this does NOT work, it seems like a bug with the recent optional
params
  ```ts
expect(matchByPath('/', '/a/b', { to: '/A/{-$id}/B', caseSensitive:
false })).toEqual({})
expect(matchByPath('/', '/a/b/2', { to: '/A/{-$id}/B/{-$other}',
caseSensitive: false })).toEqual({ other: '2' })
expect(matchByPath('/', '/a/b', { to: '/A/{-$id}/B/{-$other}',
caseSensitive: false })).toEqual({})
  ```

---------

Co-authored-by: autofix-ci[bot] <114827586+autofix-ci[bot]@users.noreply.github.com>
2025-07-23 11:58:09 +02:00
Tanner Linsley
2de6dccebe release: v1.129.8 v1.129.8 2025-07-23 09:18:33 +00:00
Flo
182df4d316
refactor(router-core): add LRU cache in front of parsePathname (#4752)
We noticed that `parsePathname` is a performance bottleneck during
navigation events. Here's a flamegraph from an application w/ ~300
routes around a navigation event:

<img width="853" height="372" alt="Screenshot 2025-07-22 at 19 36 24"
src="https://github.com/user-attachments/assets/7ed2e09a-8ea9-4170-862a-2d53c3eb4793"
/>


This PR proposes a basic least-recently-used cache implementation (that
data structure is about 4-5x slower than a `Map` according to
benchmarks, and it uses a little more memory).

We can add caching to `parsePathname` now that what it returns is
readonly (https://github.com/TanStack/router/pull/4705), which should
improve the performance of this bottleneck.

The cache is set to a size of 1000. When / if we end up making a
pre-built matcher (WIP https://github.com/TanStack/router/pull/4714), we
maybe can reduce this size. But `parsePathname` is still called w/ built
pathnames so we probably shouldn't remove the cache entirely.


When benchmarking `matchPathname` with and without the cache, we notice
a ~9x increase in throughput with the cache.
```
 ✓  @tanstack/router-core  tests/cache.bench.ts > cache.bench 7191ms
     name             hz     min     max    mean     p75     p99    p995    p999     rme  samples
   · original   1,795.61  0.5055  0.7022  0.5569  0.5604  0.6234  0.6464  0.7022  ±0.22%      898
   · cached    16,307.87  0.0562  0.2294  0.0613  0.0608  0.0767  0.1007  0.1152  ±0.17%     8154   fastest

 BENCH  Summary

   @tanstack/router-core  cached - tests/cache.bench.ts > cache.bench
    9.08x faster than original
```
Assuming this 9x increase translates to a proportional reduction of the
self-time seen in the flamegraph, it would go from 55ms to 6ms.
2025-07-23 11:16:59 +02:00
Leonardo Montini
1cd917659b
docs(router): using square brackets for character escaping (#4753) 2025-07-23 12:17:50 +12:00
Tanner Linsley
c35d414681 release: v1.129.7 v1.129.7 2025-07-23 00:13:31 +00:00
Manuel Schiller
4f930d1b80
fix: ensure unique matchId when optional and required param are on the same level (#4751) v1.129.6 2025-07-22 19:02:21 +02:00
Justin Mißmahl
d87ca5ecf4
docs: fix incorrect import path in automatic code splitting guide (#4745) 2025-07-22 18:04:23 +02:00
Tanner Linsley
ad420694a3 release: v1.129.5 v1.129.5 2025-07-22 15:38:46 +00:00
Dimitris Karagiannis
d485cc23d6
fix(router-core): type mismatch for navigate function (#4625)
According to the docs this should only return a promise
https://tanstack.com/router/latest/docs/framework/react/api/router/RouterType#navigate-method
Makes sense otherwise you cannot .then() it

---------

Co-authored-by: Nico Lynzaad <44094871+nlynzaad@users.noreply.github.com>
2025-07-22 17:32:16 +02:00
Kamlesh Paul
be1b9e39b3
docs: typo in Server-Routes => Escaped Matching (#4741) 2025-07-22 17:12:30 +02:00
Tanner Linsley
95a16365ac release: v1.129.4 v1.129.4 2025-07-22 13:53:30 +00:00
Flo
082b618cbc
refactor(router-core): improve router.comparePaths performance by not using regex (#4750)
Following up on https://github.com/TanStack/router/pull/4747
Implementation by @schiller-manuel

---------

Co-authored-by: autofix-ci[bot] <114827586+autofix-ci[bot]@users.noreply.github.com>
2025-07-22 15:52:01 +02:00
Tanner Linsley
c82415a5cd release: v1.129.3 v1.129.3 2025-07-22 11:17:11 +00:00
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