Repository: TanStack/router
Pull request #2442 (2024-09-29 19:29:35)

fix(history): correctly handle history state in `createMemoryHistory`
Fixed the behaviour of the history state in createMemoryHistory to be the same than of the browser. The current implementation doesn't handle the state correctly when traversing the history.
Also added a state test.

nx-cloud[bot]: # ☁️ Nx Cloud Report

CI is running for commit 3eb2419cc88938634cd8cd706b1831f8e1d4ecff.

[📂 Click to track the progress, see the status, the terminal output, and the build insights.](https://cloud.nx.app/cipes/66f9aab87ec41e3efcc45b60?utm_source=pull-request&utm_medium=comment)


---

Sent with 💌 from [NxCloud.](https://nx.app?utm_source=pull-request&utm_medium=comment)
pkg-pr-new[bot]: 
[Open in Stackblitz](https://pkg.pr.new/template/eb0f1011-72aa-4f7d-8433-10cf3eeab865)
<details><summary><b>More templates</b></summary><p>

- [tanstack-router-react-example-authenticated-routes](https://pkg.pr.new/template/b11a980d-9a2b-47b3-a336-f0b0ff9e5362)
- [tanstack-router-react-example-basic](https://pkg.pr.new/template/7e61410a-a4d3-41c6-a3a5-8ddacea7f54b)
- [tanstack-router-react-example-basic-default-search-params](https://pkg.pr.new/template/c6b694dd-791e-4efe-bb97-65098eaed30e)
- [tanstack-router-react-example-basic-file-based](https://pkg.pr.new/template/987df67a-de3d-483a-93e7-c4f22006dfbd)
- [tanstack-router-react-example-basic-file-based-codesplitting](https://pkg.pr.new/template/c4b88935-9e7d-4ddb-a607-0abab4d822bb)
- [tanstack-router-react-example-react-query](https://pkg.pr.new/template/e586c7a0-27fb-458c-ad24-e7000b87d3cf)
- [tanstack-router-react-example-basic-react-query-file-based](https://pkg.pr.new/template/8ec3a616-add6-44ee-9527-b0caa69b83bb)
- [tanstack-router-react-example-basic-ssr-file-based](https://pkg.pr.new/template/a7c9307d-47b7-48f7-b14c-e3919e0a5a26)
- [tanstack-router-react-example-basic-ssr-streaming-file-based](https://pkg.pr.new/template/5a508d2a-1654-4b78-bb0f-69dbf704c5c9)
- [tanstack-router-react-example-basic-virtual-file-based](https://pkg.pr.new/template/6f146e05-1a67-4459-82d3-375fc227c249)
- [tanstack-router-react-example-basic-virtual-inside-file-based](https://pkg.pr.new/template/83871dfc-d0c7-48d4-a22b-2c622d9b8326)
- [tanstack-router-react-example-deferred-data](https://pkg.pr.new/template/360eeec7-5fdf-433e-8622-0628f60efdc2)
- [tanstack-router-react-example-kitchen-sink](https://pkg.pr.new/template/cae015c2-2d04-418e-a517-0e208d493746)
- [tanstack-router-react-example-kitchen-sink-file-based](https://pkg.pr.new/template/edc9a02c-3422-4d27-aeb9-b6792bc6c212)
- [tanstack-router-react-example-kitchen-sink-react-query](https://pkg.pr.new/template/3cac16d1-b9f4-43a3-8616-c4a84e8b7cab)
- [tanstack-router-react-example-kitchen-sink-react-query-file-based](https://pkg.pr.new/template/be188a1b-8ce4-45bf-a490-28daa5fc3226)
- [tanstack-router-react-example-large-file-based](https://pkg.pr.new/template/ff565f92-5a74-44b4-996b-b7de34daf306)
- [tanstack-router-react-example-location-masking](https://pkg.pr.new/template/9fbfcac6-19d1-4f1d-9cdb-74e796dbd26c)
- [tanstack-router-react-example-navigation-blocking](https://pkg.pr.new/template/6781af48-6070-46dd-acad-5b8e207d5651)
- [tanstack-router-react-example-quickstart](https://pkg.pr.new/template/4aaefb8a-d28d-492e-b08c-ed2c47beb172)
- [tanstack-router-react-example-quickstart-file-based](https://pkg.pr.new/template/b2451738-8b07-4a84-a5ce-32bff1caefb3)
- [tanstack-router-react-example-quickstart-rspack-file-based](https://pkg.pr.new/template/213c0a17-67f9-4337-b429-27b8efa4b02d)
- [tanstack-router-react-example-quickstart-webpack-file-based](https://pkg.pr.new/template/b98c370f-3004-4ebb-b043-bd174f1b526d)
- [tanstack-router-react-example-scroll-restoration](https://pkg.pr.new/template/5c667a51-9ac9-4cbc-aa52-c67f53699c65)
- [tanstack-router-search-validator-adapters](https://pkg.pr.new/template/868c55ed-80b3-46df-acff-523b41fcbabb)
- [tanstack-start-example-basic](https://pkg.pr.new/template/eccacdcb-a7c8-41ae-93b8-9912843f7cac)
- [tanstack-start-example-basic-auth](https://pkg.pr.new/template/74fa0f3e-6d7d-421c-969f-b3ec4c549e82)
- [tanstack-start-example-basic-react-query](https://pkg.pr.new/template/f6eaee25-78cc-4bc6-ac7f-4eb92cdbd193)
- [tanstack-start-example-basic-rsc](https://pkg.pr.new/template/d0272f03-95d6-4114-8a63-59002e570be7)
- [tanstack-start-example-clerk-basic](https://pkg.pr.new/template/0b8996b7-8089-4a61-9ba5-3fabf8d467c0)
- [tanstack-start-example-convex-trellaux](https://pkg.pr.new/template/31da43d3-392d-42b3-9f0d-c8866d0c2178)
- [tanstack-start-example-counter](https://pkg.pr.new/template/c894b86e-42f8-4087-b686-2b233360f8b7)
- [tanstack-start-example-supabase-basic](https://pkg.pr.new/template/f06c5357-0cbf-41cc-ad8d-55ae7bbbd7c9)
- [tanstack-start-example-trellaux](https://pkg.pr.new/template/61b8de12-0808-4aad-88d1-04ce516343dc)
- [tanstack-router-react-example-with-framer-motion](https://pkg.pr.new/template/93dabe30-6404-4a67-9290-a09c96bd6b38)
- [tanstack-router-react-example-with-trpc](https://pkg.pr.new/template/00a9a89f-3a4c-4c40-9fbf-d929f255e1b2)
- [tanstack-router-react-example-with-trpc-react-query](https://pkg.pr.new/template/26d2df81-af95-42fc-8bfb-28229a455602)

</p></details>
      
    


<details><summary><b>@tanstack/create-router</b></summary><p>

```
pnpm add https://pkg.pr.new/@tanstack/create-router@2442
```

</p></details>
      
    

<details><summary><b>@tanstack/eslint-plugin-router</b></summary><p>

```
pnpm add https://pkg.pr.new/@tanstack/eslint-plugin-router@2442
```

</p></details>
      
    

<details><summary><b>@tanstack/history</b></summary><p>

```
pnpm add https://pkg.pr.new/@tanstack/history@2442
```

</p></details>
      
    

<details><summary><b>@tanstack/react-cross-context</b></summary><p>

```
pnpm add https://pkg.pr.new/@tanstack/react-cross-context@2442
```

</p></details>
      
    

<details><summary><b>@tanstack/react-router</b></summary><p>

```
pnpm add https://pkg.pr.new/@tanstack/react-router@2442
```

</p></details>
      
    

<details><summary><b>@tanstack/react-router-with-query</b></summary><p>

```
pnpm add https://pkg.pr.new/@tanstack/react-router-with-query@2442
```

</p></details>
      
    

<details><summary><b>@tanstack/router-arktype-adapter</b></summary><p>

```
pnpm add https://pkg.pr.new/@tanstack/router-arktype-adapter@2442
```

</p></details>
      
    

<details><summary><b>@tanstack/router-cli</b></summary><p>

```
pnpm add https://pkg.pr.new/@tanstack/router-cli@2442
```

</p></details>
      
    

<details><summary><b>@tanstack/router-devtools</b></summary><p>

```
pnpm add https://pkg.pr.new/@tanstack/router-devtools@2442
```

</p></details>
      
    

<details><summary><b>@tanstack/router-generator</b></summary><p>

```
pnpm add https://pkg.pr.new/@tanstack/router-generator@2442
```

</p></details>
      
    

<details><summary><b>@tanstack/router-plugin</b></summary><p>

```
pnpm add https://pkg.pr.new/@tanstack/router-plugin@2442
```

</p></details>
      
    

<details><summary><b>@tanstack/router-valibot-adapter</b></summary><p>

```
pnpm add https://pkg.pr.new/@tanstack/router-valibot-adapter@2442
```

</p></details>
      
    

<details><summary><b>@tanstack/router-vite-plugin</b></summary><p>

```
pnpm add https://pkg.pr.new/@tanstack/router-vite-plugin@2442
```

</p></details>
      
    

<details><summary><b>@tanstack/router-zod-adapter</b></summary><p>

```
pnpm add https://pkg.pr.new/@tanstack/router-zod-adapter@2442
```

</p></details>
      
    

<details><summary><b>@tanstack/start</b></summary><p>

```
pnpm add https://pkg.pr.new/@tanstack/start@2442
```

</p></details>
      
    

<details><summary><b>@tanstack/start-vite-plugin</b></summary><p>

```
pnpm add https://pkg.pr.new/@tanstack/start-vite-plugin@2442
```

</p></details>
      
    

<details><summary><b>@tanstack/virtual-file-routes</b></summary><p>

```
pnpm add https://pkg.pr.new/@tanstack/virtual-file-routes@2442
```

</p></details>
      
    

_commit: <a href="https://github.com/TanStack/router/runs/30823918455"><code>8be8b30</code></a>_


Patch:
diff --git a/examples/react/authenticated-routes/package.json b/examples/react/authenticated-routes/package.json
index 2f204e2c5..32b06a7fb 100644
--- a/examples/react/authenticated-routes/package.json
+++ b/examples/react/authenticated-routes/package.json
@@ -9,8 +9,8 @@
     "start": "vite"
   },
   "dependencies": {
-    "@tanstack/react-router": "^1.60.0",
-    "@tanstack/router-devtools": "^1.60.0",
+    "@tanstack/react-router": "^1.61.0",
+    "@tanstack/router-devtools": "^1.61.0",
     "@tanstack/router-plugin": "^1.60.0",
     "react": "^18.2.0",
     "react-dom": "^18.2.0",
diff --git a/examples/react/basic-default-search-params/package.json b/examples/react/basic-default-search-params/package.json
index ac3944711..311300b14 100644
--- a/examples/react/basic-default-search-params/package.json
+++ b/examples/react/basic-default-search-params/package.json
@@ -10,8 +10,8 @@
   },
   "dependencies": {
     "@tanstack/react-query": "^5.59.0",
-    "@tanstack/react-router": "^1.60.0",
-    "@tanstack/router-devtools": "^1.60.0",
+    "@tanstack/react-router": "^1.61.0",
+    "@tanstack/router-devtools": "^1.61.0",
     "redaxios": "^0.5.1",
     "react": "^18.2.0",
     "react-dom": "^18.2.0",
diff --git a/examples/react/basic-file-based-codesplitting/package.json b/examples/react/basic-file-based-codesplitting/package.json
index d2d1f1aa7..6189ed05a 100644
--- a/examples/react/basic-file-based-codesplitting/package.json
+++ b/examples/react/basic-file-based-codesplitting/package.json
@@ -9,8 +9,8 @@
     "start": "vite"
   },
   "dependencies": {
-    "@tanstack/react-router": "^1.60.0",
-    "@tanstack/router-devtools": "^1.60.0",
+    "@tanstack/react-router": "^1.61.0",
+    "@tanstack/router-devtools": "^1.61.0",
     "@tanstack/router-plugin": "^1.60.0",
     "react": "^18.2.0",
     "react-dom": "^18.2.0",
diff --git a/examples/react/basic-file-based/package.json b/examples/react/basic-file-based/package.json
index 39c75ceb9..a815bad02 100644
--- a/examples/react/basic-file-based/package.json
+++ b/examples/react/basic-file-based/package.json
@@ -9,8 +9,8 @@
     "start": "vite"
   },
   "dependencies": {
-    "@tanstack/react-router": "^1.60.0",
-    "@tanstack/router-devtools": "^1.60.0",
+    "@tanstack/react-router": "^1.61.0",
+    "@tanstack/router-devtools": "^1.61.0",
     "@tanstack/router-plugin": "^1.60.0",
     "react": "^18.2.0",
     "react-dom": "^18.2.0",
diff --git a/examples/react/basic-react-query-file-based/package.json b/examples/react/basic-react-query-file-based/package.json
index 96c8ffdd8..82f35283f 100644
--- a/examples/react/basic-react-query-file-based/package.json
+++ b/examples/react/basic-react-query-file-based/package.json
@@ -11,8 +11,8 @@
   "dependencies": {
     "@tanstack/react-query": "^5.59.0",
     "@tanstack/react-query-devtools": "^5.59.0",
-    "@tanstack/react-router": "^1.60.0",
-    "@tanstack/router-devtools": "^1.60.0",
+    "@tanstack/react-router": "^1.61.0",
+    "@tanstack/router-devtools": "^1.61.0",
     "@tanstack/router-plugin": "^1.60.0",
     "immer": "^10.1.1",
     "react": "^18.2.0",
diff --git a/examples/react/basic-react-query/package.json b/examples/react/basic-react-query/package.json
index e97d46c1c..305ab57b9 100644
--- a/examples/react/basic-react-query/package.json
+++ b/examples/react/basic-react-query/package.json
@@ -11,8 +11,8 @@
   "dependencies": {
     "@tanstack/react-query": "^5.59.0",
     "@tanstack/react-query-devtools": "^5.59.0",
-    "@tanstack/react-router": "^1.60.0",
-    "@tanstack/router-devtools": "^1.60.0",
+    "@tanstack/react-router": "^1.61.0",
+    "@tanstack/router-devtools": "^1.61.0",
     "react": "^18.2.0",
     "react-dom": "^18.2.0",
     "redaxios": "^0.5.1"
diff --git a/examples/react/basic-ssr-file-based/package.json b/examples/react/basic-ssr-file-based/package.json
index f8aa437c0..d2e84002b 100644
--- a/examples/react/basic-ssr-file-based/package.json
+++ b/examples/react/basic-ssr-file-based/package.json
@@ -11,10 +11,10 @@
     "debug": "node --inspect-brk server"
   },
   "dependencies": {
-    "@tanstack/react-router": "^1.60.0",
-    "@tanstack/router-devtools": "^1.60.0",
+    "@tanstack/react-router": "^1.61.0",
+    "@tanstack/router-devtools": "^1.61.0",
     "@tanstack/router-plugin": "^1.60.0",
-    "@tanstack/start": "^1.60.0",
+    "@tanstack/start": "^1.61.0",
     "get-port": "^7.1.0",
     "react": "^18.2.0",
     "react-dom": "^18.2.0",
diff --git a/examples/react/basic-ssr-streaming-file-based/package.json b/examples/react/basic-ssr-streaming-file-based/package.json
index 2ecdd91c5..212a21586 100644
--- a/examples/react/basic-ssr-streaming-file-based/package.json
+++ b/examples/react/basic-ssr-streaming-file-based/package.json
@@ -11,10 +11,10 @@
     "debug": "node --inspect-brk server"
   },
   "dependencies": {
-    "@tanstack/react-router": "^1.60.0",
-    "@tanstack/router-devtools": "^1.60.0",
+    "@tanstack/react-router": "^1.61.0",
+    "@tanstack/router-devtools": "^1.61.0",
     "@tanstack/router-plugin": "^1.60.0",
-    "@tanstack/start": "^1.60.0",
+    "@tanstack/start": "^1.61.0",
     "get-port": "^7.1.0",
     "react": "^18.2.0",
     "react-dom": "^18.2.0",
diff --git a/examples/react/basic-virtual-file-based/package.json b/examples/react/basic-virtual-file-based/package.json
index 4288840e0..e2c28a582 100644
--- a/examples/react/basic-virtual-file-based/package.json
+++ b/examples/react/basic-virtual-file-based/package.json
@@ -9,8 +9,8 @@
     "start": "vite"
   },
   "dependencies": {
-    "@tanstack/react-router": "^1.60.0",
-    "@tanstack/router-devtools": "^1.60.0",
+    "@tanstack/react-router": "^1.61.0",
+    "@tanstack/router-devtools": "^1.61.0",
     "@tanstack/router-plugin": "^1.60.0",
     "@tanstack/virtual-file-routes": "^1.56.0",
     "immer": "^10.1.1",
diff --git a/examples/react/basic-virtual-inside-file-based/package.json b/examples/react/basic-virtual-inside-file-based/package.json
index be0fec13e..5ec178b32 100644
--- a/examples/react/basic-virtual-inside-file-based/package.json
+++ b/examples/react/basic-virtual-inside-file-based/package.json
@@ -9,8 +9,8 @@
     "start": "vite"
   },
   "dependencies": {
-    "@tanstack/react-router": "^1.60.0",
-    "@tanstack/router-devtools": "^1.60.0",
+    "@tanstack/react-router": "^1.61.0",
+    "@tanstack/router-devtools": "^1.61.0",
     "@tanstack/router-plugin": "^1.60.0",
     "@tanstack/virtual-file-routes": "^1.56.0",
     "immer": "^10.1.1",
diff --git a/examples/react/basic/package.json b/examples/react/basic/package.json
index 46fb17b75..d02d00501 100644
--- a/examples/react/basic/package.json
+++ b/examples/react/basic/package.json
@@ -9,8 +9,8 @@
     "start": "vite"
   },
   "dependencies": {
-    "@tanstack/react-router": "^1.60.0",
-    "@tanstack/router-devtools": "^1.60.0",
+    "@tanstack/react-router": "^1.61.0",
+    "@tanstack/router-devtools": "^1.61.0",
     "react": "^18.2.0",
     "react-dom": "^18.2.0",
     "redaxios": "^0.5.1"
diff --git a/examples/react/deferred-data/package.json b/examples/react/deferred-data/package.json
index 0e95208c9..a4920b4e9 100644
--- a/examples/react/deferred-data/package.json
+++ b/examples/react/deferred-data/package.json
@@ -9,8 +9,8 @@
     "start": "vite"
   },
   "dependencies": {
-    "@tanstack/react-router": "^1.60.0",
-    "@tanstack/router-devtools": "^1.60.0",
+    "@tanstack/react-router": "^1.61.0",
+    "@tanstack/router-devtools": "^1.61.0",
     "redaxios": "^0.5.1",
     "react": "^18.2.0",
     "react-dom": "^18.2.0",
diff --git a/examples/react/kitchen-sink-file-based/package.json b/examples/react/kitchen-sink-file-based/package.json
index b046b4aca..f446cd0af 100644
--- a/examples/react/kitchen-sink-file-based/package.json
+++ b/examples/react/kitchen-sink-file-based/package.json
@@ -9,8 +9,8 @@
     "start": "vite"
   },
   "dependencies": {
-    "@tanstack/react-router": "^1.60.0",
-    "@tanstack/router-devtools": "^1.60.0",
+    "@tanstack/react-router": "^1.61.0",
+    "@tanstack/router-devtools": "^1.61.0",
     "@tanstack/router-plugin": "^1.60.0",
     "immer": "^10.1.1",
     "react": "^18.2.0",
diff --git a/examples/react/kitchen-sink-react-query-file-based/package.json b/examples/react/kitchen-sink-react-query-file-based/package.json
index 3384cbe3e..dfd7cbf35 100644
--- a/examples/react/kitchen-sink-react-query-file-based/package.json
+++ b/examples/react/kitchen-sink-react-query-file-based/package.json
@@ -11,8 +11,8 @@
   "dependencies": {
     "@tanstack/react-query": "^5.59.0",
     "@tanstack/react-query-devtools": "^5.59.0",
-    "@tanstack/react-router": "^1.60.0",
-    "@tanstack/router-devtools": "^1.60.0",
+    "@tanstack/react-router": "^1.61.0",
+    "@tanstack/router-devtools": "^1.61.0",
     "@tanstack/router-plugin": "^1.60.0",
     "immer": "^10.1.1",
     "react": "^18.2.0",
diff --git a/examples/react/kitchen-sink-react-query/package.json b/examples/react/kitchen-sink-react-query/package.json
index 0c1410d70..6b59c9911 100644
--- a/examples/react/kitchen-sink-react-query/package.json
+++ b/examples/react/kitchen-sink-react-query/package.json
@@ -11,8 +11,8 @@
   "dependencies": {
     "@tanstack/react-query": "^5.59.0",
     "@tanstack/react-query-devtools": "^5.59.0",
-    "@tanstack/react-router": "^1.60.0",
-    "@tanstack/router-devtools": "^1.60.0",
+    "@tanstack/react-router": "^1.61.0",
+    "@tanstack/router-devtools": "^1.61.0",
     "redaxios": "^0.5.1",
     "immer": "^10.1.1",
     "react": "^18.2.0",
diff --git a/examples/react/kitchen-sink/package.json b/examples/react/kitchen-sink/package.json
index 2f68bf493..f38077960 100644
--- a/examples/react/kitchen-sink/package.json
+++ b/examples/react/kitchen-sink/package.json
@@ -9,8 +9,8 @@
     "start": "vite"
   },
   "dependencies": {
-    "@tanstack/react-router": "^1.60.0",
-    "@tanstack/router-devtools": "^1.60.0",
+    "@tanstack/react-router": "^1.61.0",
+    "@tanstack/router-devtools": "^1.61.0",
     "redaxios": "^0.5.1",
     "immer": "^10.1.1",
     "react": "^18.2.0",
diff --git a/examples/react/large-file-based/package.json b/examples/react/large-file-based/package.json
index 4723314f0..451374a1a 100644
--- a/examples/react/large-file-based/package.json
+++ b/examples/react/large-file-based/package.json
@@ -12,8 +12,8 @@
   },
   "dependencies": {
     "@tanstack/react-query": "^5.59.0",
-    "@tanstack/react-router": "^1.60.0",
-    "@tanstack/router-devtools": "^1.60.0",
+    "@tanstack/react-router": "^1.61.0",
+    "@tanstack/router-devtools": "^1.61.0",
     "@tanstack/router-plugin": "^1.60.0",
     "react": "^18.2.0",
     "react-dom": "^18.2.0",
diff --git a/examples/react/location-masking/package.json b/examples/react/location-masking/package.json
index 298142a75..ad0b1c3de 100644
--- a/examples/react/location-masking/package.json
+++ b/examples/react/location-masking/package.json
@@ -11,8 +11,8 @@
   "dependencies": {
     "@radix-ui/react-dialog": "^1.1.2",
     "@tanstack/react-query": "^5.59.0",
-    "@tanstack/react-router": "^1.60.0",
-    "@tanstack/router-devtools": "^1.60.0",
+    "@tanstack/react-router": "^1.61.0",
+    "@tanstack/router-devtools": "^1.61.0",
     "redaxios": "^0.5.1",
     "react": "^18.2.0",
     "react-dom": "^18.2.0"
diff --git a/examples/react/navigation-blocking/package.json b/examples/react/navigation-blocking/package.json
index 37818b30a..a5ce7853e 100644
--- a/examples/react/navigation-blocking/package.json
+++ b/examples/react/navigation-blocking/package.json
@@ -10,8 +10,8 @@
   },
   "dependencies": {
     "@tanstack/react-query": "^5.59.0",
-    "@tanstack/react-router": "^1.60.0",
-    "@tanstack/router-devtools": "^1.60.0",
+    "@tanstack/react-router": "^1.61.0",
+    "@tanstack/router-devtools": "^1.61.0",
     "redaxios": "^0.5.1",
     "react": "^18.2.0",
     "react-dom": "^18.2.0"
diff --git a/examples/react/quickstart-file-based/package.json b/examples/react/quickstart-file-based/package.json
index c494d5be3..003cfb0d1 100644
--- a/examples/react/quickstart-file-based/package.json
+++ b/examples/react/quickstart-file-based/package.json
@@ -9,8 +9,8 @@
     "start": "vite"
   },
   "dependencies": {
-    "@tanstack/react-router": "^1.60.0",
-    "@tanstack/router-devtools": "^1.60.0",
+    "@tanstack/react-router": "^1.61.0",
+    "@tanstack/router-devtools": "^1.61.0",
     "@tanstack/router-plugin": "^1.60.0",
     "react": "^18.2.0",
     "react-dom": "^18.2.0",
diff --git a/examples/react/quickstart-rspack-file-based/package.json b/examples/react/quickstart-rspack-file-based/package.json
index 809542552..fa87fb6f5 100644
--- a/examples/react/quickstart-rspack-file-based/package.json
+++ b/examples/react/quickstart-rspack-file-based/package.json
@@ -8,8 +8,8 @@
     "preview": "rsbuild preview"
   },
   "dependencies": {
-    "@tanstack/react-router": "^1.60.0",
-    "@tanstack/router-devtools": "^1.60.0",
+    "@tanstack/react-router": "^1.61.0",
+    "@tanstack/router-devtools": "^1.61.0",
     "react": "^18.3.1",
     "react-dom": "^18.3.1"
   },
diff --git a/examples/react/quickstart-webpack-file-based/package.json b/examples/react/quickstart-webpack-file-based/package.json
index 4b640acac..0b03bf723 100644
--- a/examples/react/quickstart-webpack-file-based/package.json
+++ b/examples/react/quickstart-webpack-file-based/package.json
@@ -7,8 +7,8 @@
     "build": "webpack build && tsc --noEmit"
   },
   "dependencies": {
-    "@tanstack/react-router": "^1.60.0",
-    "@tanstack/router-devtools": "^1.60.0",
+    "@tanstack/react-router": "^1.61.0",
+    "@tanstack/router-devtools": "^1.61.0",
     "react": "^18.3.1",
     "react-dom": "^18.3.1"
   },
diff --git a/examples/react/quickstart/package.json b/examples/react/quickstart/package.json
index c7bf0f79d..ef09114f5 100644
--- a/examples/react/quickstart/package.json
+++ b/examples/react/quickstart/package.json
@@ -9,8 +9,8 @@
     "start": "vite"
   },
   "dependencies": {
-    "@tanstack/react-router": "^1.60.0",
-    "@tanstack/router-devtools": "^1.60.0",
+    "@tanstack/react-router": "^1.61.0",
+    "@tanstack/router-devtools": "^1.61.0",
     "react": "^18.2.0",
     "react-dom": "^18.2.0"
   },
diff --git a/examples/react/scroll-restoration/package.json b/examples/react/scroll-restoration/package.json
index 9243720bc..1c6826b08 100644
--- a/examples/react/scroll-restoration/package.json
+++ b/examples/react/scroll-restoration/package.json
@@ -9,9 +9,9 @@
     "start": "vite"
   },
   "dependencies": {
-    "@tanstack/react-router": "^1.60.0",
+    "@tanstack/react-router": "^1.61.0",
     "@tanstack/react-virtual": "^3.10.8",
-    "@tanstack/router-devtools": "^1.60.0",
+    "@tanstack/router-devtools": "^1.61.0",
     "react": "^18.2.0",
     "react-dom": "^18.2.0"
   },
diff --git a/examples/react/search-validator-adapters/package.json b/examples/react/search-validator-adapters/package.json
index 8b768450a..a78b3327f 100644
--- a/examples/react/search-validator-adapters/package.json
+++ b/examples/react/search-validator-adapters/package.json
@@ -10,12 +10,12 @@
   },
   "dependencies": {
     "@tanstack/react-query": "^5.59.0",
-    "@tanstack/react-router": "^1.60.0",
-    "@tanstack/router-arktype-adapter": "^1.60.0",
-    "@tanstack/router-devtools": "^1.60.0",
+    "@tanstack/react-router": "^1.61.0",
+    "@tanstack/router-arktype-adapter": "^1.61.0",
+    "@tanstack/router-devtools": "^1.61.0",
     "@tanstack/router-plugin": "^1.60.0",
-    "@tanstack/router-valibot-adapter": "^1.60.0",
-    "@tanstack/router-zod-adapter": "^1.60.0",
+    "@tanstack/router-valibot-adapter": "^1.61.0",
+    "@tanstack/router-zod-adapter": "^1.61.0",
     "arktype": "^2.0.0-rc.14",
     "react": "^18.2.0",
     "react-dom": "^18.2.0",
diff --git a/examples/react/start-basic-auth/package.json b/examples/react/start-basic-auth/package.json
index 22c06f7fa..2002bdd14 100644
--- a/examples/react/start-basic-auth/package.json
+++ b/examples/react/start-basic-auth/package.json
@@ -11,9 +11,9 @@
   },
   "dependencies": {
     "@prisma/client": "5.20.0",
-    "@tanstack/react-router": "^1.60.0",
-    "@tanstack/router-devtools": "^1.60.0",
-    "@tanstack/start": "^1.60.0",
+    "@tanstack/react-router": "^1.61.0",
+    "@tanstack/router-devtools": "^1.61.0",
+    "@tanstack/start": "^1.61.0",
     "dotenv": "^16.4.5",
     "prisma": "^5.20.0",
     "react": "^18.3.1",
diff --git a/examples/react/start-basic-react-query/package.json b/examples/react/start-basic-react-query/package.json
index 19b1ec7e1..cc37596d5 100644
--- a/examples/react/start-basic-react-query/package.json
+++ b/examples/react/start-basic-react-query/package.json
@@ -11,10 +11,10 @@
   "dependencies": {
     "@tanstack/react-query": "^5.59.0",
     "@tanstack/react-query-devtools": "^5.59.0",
-    "@tanstack/react-router": "^1.60.0",
-    "@tanstack/react-router-with-query": "^1.60.0",
-    "@tanstack/router-devtools": "^1.60.0",
-    "@tanstack/start": "^1.60.0",
+    "@tanstack/react-router": "^1.61.0",
+    "@tanstack/react-router-with-query": "^1.61.0",
+    "@tanstack/router-devtools": "^1.61.0",
+    "@tanstack/start": "^1.61.0",
     "react": "^18.3.1",
     "react-dom": "^18.3.1",
     "redaxios": "^0.5.1",
diff --git a/examples/react/start-basic-rsc/package.json b/examples/react/start-basic-rsc/package.json
index a0b425e7b..7d358ceeb 100644
--- a/examples/react/start-basic-rsc/package.json
+++ b/examples/react/start-basic-rsc/package.json
@@ -10,9 +10,9 @@
   },
   "dependencies": {
     "@babel/plugin-syntax-typescript": "^7.25.7",
-    "@tanstack/react-router": "^1.60.0",
-    "@tanstack/router-devtools": "^1.60.0",
-    "@tanstack/start": "^1.60.0",
+    "@tanstack/react-router": "^1.61.0",
+    "@tanstack/router-devtools": "^1.61.0",
+    "@tanstack/start": "^1.61.0",
     "redaxios": "^0.5.1",
     "tailwind-merge": "^2.5.3",
     "vinxi": "0.4.3"
diff --git a/examples/react/start-basic/package.json b/examples/react/start-basic/package.json
index 6bcb0e503..912717c6d 100644
--- a/examples/react/start-basic/package.json
+++ b/examples/react/start-basic/package.json
@@ -9,9 +9,9 @@
     "start": "vinxi start"
   },
   "dependencies": {
-    "@tanstack/react-router": "^1.60.0",
-    "@tanstack/router-devtools": "^1.60.0",
-    "@tanstack/start": "^1.60.0",
+    "@tanstack/react-router": "^1.61.0",
+    "@tanstack/router-devtools": "^1.61.0",
+    "@tanstack/start": "^1.61.0",
     "react": "^18.3.1",
     "react-dom": "^18.3.1",
     "redaxios": "^0.5.1",
diff --git a/examples/react/start-clerk-basic/package.json b/examples/react/start-clerk-basic/package.json
index 52582ea77..824e67d68 100644
--- a/examples/react/start-clerk-basic/package.json
+++ b/examples/react/start-clerk-basic/package.json
@@ -10,9 +10,9 @@
   },
   "dependencies": {
     "@clerk/tanstack-start": "0.4.11",
-    "@tanstack/react-router": "^1.60.0",
-    "@tanstack/router-devtools": "^1.60.0",
-    "@tanstack/start": "^1.60.0",
+    "@tanstack/react-router": "^1.61.0",
+    "@tanstack/router-devtools": "^1.61.0",
+    "@tanstack/start": "^1.61.0",
     "dotenv": "^16.4.5",
     "react": "^18.3.1",
     "react-dom": "^18.3.1",
diff --git a/examples/react/start-convex-trellaux/package.json b/examples/react/start-convex-trellaux/package.json
index 385d7115d..bd2a0187a 100644
--- a/examples/react/start-convex-trellaux/package.json
+++ b/examples/react/start-convex-trellaux/package.json
@@ -13,10 +13,10 @@
   "dependencies": {
     "@tanstack/react-query": "^5.59.0",
     "@tanstack/react-query-devtools": "^5.59.0",
-    "@tanstack/react-router": "^1.60.0",
-    "@tanstack/react-router-with-query": "^1.60.0",
-    "@tanstack/router-devtools": "^1.60.0",
-    "@tanstack/start": "^1.60.0",
+    "@tanstack/react-router": "^1.61.0",
+    "@tanstack/react-router-with-query": "^1.61.0",
+    "@tanstack/router-devtools": "^1.61.0",
+    "@tanstack/start": "^1.61.0",
     "@convex-dev/react-query": "0.0.0-alpha.5",
     "concurrently": "^8.2.2",
     "convex": "^1.16.3",
diff --git a/examples/react/start-counter/package.json b/examples/react/start-counter/package.json
index 7499f7e90..dc159be53 100644
--- a/examples/react/start-counter/package.json
+++ b/examples/react/start-counter/package.json
@@ -9,8 +9,8 @@
     "start": "vinxi start"
   },
   "dependencies": {
-    "@tanstack/react-router": "^1.60.0",
-    "@tanstack/start": "^1.60.0",
+    "@tanstack/react-router": "^1.61.0",
+    "@tanstack/start": "^1.61.0",
     "react": "^18.3.1",
     "react-dom": "^18.3.1",
     "vinxi": "0.4.3"
diff --git a/examples/react/start-supabase-basic/package.json b/examples/react/start-supabase-basic/package.json
index ededbef45..f8df9feae 100644
--- a/examples/react/start-supabase-basic/package.json
+++ b/examples/react/start-supabase-basic/package.json
@@ -15,9 +15,9 @@
   "dependencies": {
     "@supabase/ssr": "^0.5.1",
     "@supabase/supabase-js": "^2.45.4",
-    "@tanstack/react-router": "^1.60.0",
-    "@tanstack/router-devtools": "^1.60.0",
-    "@tanstack/start": "^1.60.0",
+    "@tanstack/react-router": "^1.61.0",
+    "@tanstack/router-devtools": "^1.61.0",
+    "@tanstack/start": "^1.61.0",
     "@vitejs/plugin-react": "^4.3.2",
     "react": "^18.3.1",
     "react-dom": "^18.3.1",
diff --git a/examples/react/start-trellaux/package.json b/examples/react/start-trellaux/package.json
index e7c8e7cb9..cf3828e0f 100644
--- a/examples/react/start-trellaux/package.json
+++ b/examples/react/start-trellaux/package.json
@@ -11,10 +11,10 @@
   "dependencies": {
     "@tanstack/react-query": "^5.59.0",
     "@tanstack/react-query-devtools": "^5.59.0",
-    "@tanstack/react-router": "^1.60.0",
-    "@tanstack/react-router-with-query": "^1.60.0",
-    "@tanstack/router-devtools": "^1.60.0",
-    "@tanstack/start": "^1.60.0",
+    "@tanstack/react-router": "^1.61.0",
+    "@tanstack/react-router-with-query": "^1.61.0",
+    "@tanstack/router-devtools": "^1.61.0",
+    "@tanstack/start": "^1.61.0",
     "ky": "^1.7.2",
     "msw": "^2.4.9",
     "react": "^18.3.1",
diff --git a/examples/react/with-framer-motion/package.json b/examples/react/with-framer-motion/package.json
index 635758743..217cfe672 100644
--- a/examples/react/with-framer-motion/package.json
+++ b/examples/react/with-framer-motion/package.json
@@ -9,8 +9,8 @@
     "start": "vite"
   },
   "dependencies": {
-    "@tanstack/react-router": "^1.60.0",
-    "@tanstack/router-devtools": "^1.60.0",
+    "@tanstack/react-router": "^1.61.0",
+    "@tanstack/router-devtools": "^1.61.0",
     "redaxios": "^0.5.1",
     "framer-motion": "^11.11.1",
     "react": "^18.2.0",
diff --git a/examples/react/with-trpc-react-query/package.json b/examples/react/with-trpc-react-query/package.json
index 2e39c4448..c42bde96f 100644
--- a/examples/react/with-trpc-react-query/package.json
+++ b/examples/react/with-trpc-react-query/package.json
@@ -10,8 +10,8 @@
   "dependencies": {
     "@tanstack/react-query": "^5.59.0",
     "@tanstack/react-query-devtools": "^5.59.0",
-    "@tanstack/react-router": "^1.60.0",
-    "@tanstack/router-devtools": "^1.60.0",
+    "@tanstack/react-router": "^1.61.0",
+    "@tanstack/router-devtools": "^1.61.0",
     "@tanstack/router-plugin": "^1.60.0",
     "@trpc/client": "11.0.0-rc.553",
     "@trpc/react-query": "11.0.0-rc.553",
diff --git a/examples/react/with-trpc/package.json b/examples/react/with-trpc/package.json
index 2ffeb7851..77964ef92 100644
--- a/examples/react/with-trpc/package.json
+++ b/examples/react/with-trpc/package.json
@@ -8,8 +8,8 @@
     "start": "vinxi start"
   },
   "dependencies": {
-    "@tanstack/react-router": "^1.60.0",
-    "@tanstack/router-devtools": "^1.60.0",
+    "@tanstack/react-router": "^1.61.0",
+    "@tanstack/router-devtools": "^1.61.0",
     "@tanstack/router-plugin": "^1.60.0",
     "@trpc/client": "11.0.0-rc.553",
     "@trpc/server": "11.0.0-rc.553",
diff --git a/packages/create-router/package.json b/packages/create-router/package.json
index 7ec6cc772..b677c1908 100644
--- a/packages/create-router/package.json
+++ b/packages/create-router/package.json
@@ -1,6 +1,6 @@
 {
   "name": "@tanstack/create-router",
-  "version": "1.60.0",
+  "version": "1.61.0",
   "description": "Modern and scalable routing for React applications",
   "author": "Tanner Linsley",
   "license": "MIT",
diff --git a/packages/history/package.json b/packages/history/package.json
index 44625b9bb..06cbe0c85 100644
--- a/packages/history/package.json
+++ b/packages/history/package.json
@@ -1,6 +1,6 @@
 {
   "name": "@tanstack/history",
-  "version": "1.58.15",
+  "version": "1.61.0",
   "description": "Modern and scalable routing for React applications",
   "author": "Tanner Linsley",
   "license": "MIT",
diff --git a/packages/history/src/index.ts b/packages/history/src/index.ts
index 72b2e6aec..956c4f93c 100644
--- a/packages/history/src/index.ts
+++ b/packages/history/src/index.ts
@@ -366,38 +366,34 @@ export function createMemoryHistory(
 ): RouterHistory {
   const entries = opts.initialEntries
   let index = opts.initialIndex ?? entries.length - 1
-  let currentState = {
-    key: createRandomKey(),
-  } as HistoryState
+  const states = entries.map(() => ({}) as HistoryState)
 
-  const getLocation = () => parseHref(entries[index]!, currentState)
+  const getLocation = () => parseHref(entries[index]!, states[index])
 
   return createHistory({
     getLocation,
     getLength: () => entries.length,
     pushState: (path, state) => {
-      currentState = state
       // Removes all subsequent entries after the current index to start a new branch
       if (index < entries.length - 1) {
         entries.splice(index + 1)
+        states.splice(index + 1)
       }
+      states.push(state)
       entries.push(path)
       index = Math.max(entries.length - 1, 0)
     },
     replaceState: (path, state) => {
-      currentState = state
+      states[index] = state
       entries[index] = path
     },
     back: () => {
-      currentState = assignKey(currentState)
       index = Math.max(index - 1, 0)
     },
     forward: () => {
-      currentState = assignKey(currentState)
       index = Math.min(index + 1, entries.length - 1)
     },
     go: (n) => {
-      currentState = assignKey(currentState)
       index = Math.min(Math.max(index + n, 0), entries.length - 1)
     },
     createHref: (path) => path,
diff --git a/packages/react-router-with-query/package.json b/packages/react-router-with-query/package.json
index 7d94b5d48..c7141e30e 100644
--- a/packages/react-router-with-query/package.json
+++ b/packages/react-router-with-query/package.json
@@ -1,6 +1,6 @@
 {
   "name": "@tanstack/react-router-with-query",
-  "version": "1.60.0",
+  "version": "1.61.0",
   "description": "Modern and scalable routing for React applications",
   "author": "Tanner Linsley",
   "license": "MIT",
diff --git a/packages/react-router/package.json b/packages/react-router/package.json
index f245db4ff..ada61548a 100644
--- a/packages/react-router/package.json
+++ b/packages/react-router/package.json
@@ -1,6 +1,6 @@
 {
   "name": "@tanstack/react-router",
-  "version": "1.60.0",
+  "version": "1.61.0",
   "description": "Modern and scalable routing for React applications",
   "author": "Tanner Linsley",
   "license": "MIT",
diff --git a/packages/router-arktype-adapter/package.json b/packages/router-arktype-adapter/package.json
index bb0ebdb7b..12f579d7c 100644
--- a/packages/router-arktype-adapter/package.json
+++ b/packages/router-arktype-adapter/package.json
@@ -1,6 +1,6 @@
 {
   "name": "@tanstack/router-arktype-adapter",
-  "version": "1.60.0",
+  "version": "1.61.0",
   "description": "Modern and scalable routing for React applications",
   "author": "Tanner Linsley",
   "license": "MIT",
diff --git a/packages/router-devtools/package.json b/packages/router-devtools/package.json
index 528a811b7..3e5cba15a 100644
--- a/packages/router-devtools/package.json
+++ b/packages/router-devtools/package.json
@@ -1,6 +1,6 @@
 {
   "name": "@tanstack/router-devtools",
-  "version": "1.60.0",
+  "version": "1.61.0",
   "description": "Modern and scalable routing for React applications",
   "author": "Tanner Linsley",
   "license": "MIT",
diff --git a/packages/router-valibot-adapter/package.json b/packages/router-valibot-adapter/package.json
index 0a496678b..056eab2c0 100644
--- a/packages/router-valibot-adapter/package.json
+++ b/packages/router-valibot-adapter/package.json
@@ -1,6 +1,6 @@
 {
   "name": "@tanstack/router-valibot-adapter",
-  "version": "1.60.0",
+  "version": "1.61.0",
   "description": "Modern and scalable routing for React applications",
   "author": "Tanner Linsley",
   "license": "MIT",
diff --git a/packages/router-zod-adapter/package.json b/packages/router-zod-adapter/package.json
index 68bb4a085..4de452ce5 100644
--- a/packages/router-zod-adapter/package.json
+++ b/packages/router-zod-adapter/package.json
@@ -1,6 +1,6 @@
 {
   "name": "@tanstack/router-zod-adapter",
-  "version": "1.60.0",
+  "version": "1.61.0",
   "description": "Modern and scalable routing for React applications",
   "author": "Tanner Linsley",
   "license": "MIT",
diff --git a/packages/start/package.json b/packages/start/package.json
index b9489f624..e23b860d1 100644
--- a/packages/start/package.json
+++ b/packages/start/package.json
@@ -1,6 +1,6 @@
 {
   "name": "@tanstack/start",
-  "version": "1.60.0",
+  "version": "1.61.0",
   "description": "Modern and scalable routing for React applications",
   "author": "Tanner Linsley",
   "license": "MIT",


Test patch:
diff --git a/packages/history/tests/createMemoryHistory.test.ts b/packages/history/tests/createMemoryHistory.test.ts
index aae09a9bf..caddb96ac 100644
--- a/packages/history/tests/createMemoryHistory.test.ts
+++ b/packages/history/tests/createMemoryHistory.test.ts
@@ -64,4 +64,16 @@ describe('createMemoryHistory', () => {
     history.push('/c')
     expect(history.length).toBe(2)
   })
+
+  test('state', () => {
+    const history = createMemoryHistory()
+    history.push('/a', { i: 1 })
+    expect((history.location.state as any).i).toBe(1)
+    history.replace('/b', { i: 2 })
+    expect((history.location.state as any).i).toBe(2)
+    history.back()
+    expect((history.location.state as any).i).toBeUndefined()
+    history.push('/c', { i: 3 })
+    expect((history.location.state as any).i).toBe(3)
+  })
 })