diff --git a/.github/workflows/autofix.yml b/.github/workflows/autofix.yml
index c7687a24de..593d08409f 100644
--- a/.github/workflows/autofix.yml
+++ b/.github/workflows/autofix.yml
@@ -18,7 +18,7 @@ jobs:
runs-on: ubuntu-latest
steps:
- name: Checkout
- uses: actions/checkout@v4.2.1
+ uses: actions/checkout@v4.2.2
- name: Setup Tools
uses: tanstack/config/.github/setup@main
- name: Fix formatting
diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml
index 5218ce3ff1..edca1c876d 100644
--- a/.github/workflows/ci.yml
+++ b/.github/workflows/ci.yml
@@ -27,7 +27,7 @@ jobs:
runs-on: ubuntu-latest
steps:
- name: Checkout
- uses: actions/checkout@v4.2.1
+ uses: actions/checkout@v4.2.2
with:
fetch-depth: 0
- name: Start Nx Agents
diff --git a/.github/workflows/pr.yml b/.github/workflows/pr.yml
index fca1e87bb0..40e97819d8 100644
--- a/.github/workflows/pr.yml
+++ b/.github/workflows/pr.yml
@@ -19,7 +19,7 @@ jobs:
runs-on: ubuntu-latest
steps:
- name: Checkout
- uses: actions/checkout@v4.2.1
+ uses: actions/checkout@v4.2.2
with:
fetch-depth: 0
- name: Start Nx Agents
@@ -40,7 +40,7 @@ jobs:
runs-on: ubuntu-latest
steps:
- name: Checkout
- uses: actions/checkout@v4.2.1
+ uses: actions/checkout@v4.2.2
with:
fetch-depth: 0
- name: Setup Tools
diff --git a/.gitignore b/.gitignore
index ce8d7b7cd9..b45b389c0d 100644
--- a/.gitignore
+++ b/.gitignore
@@ -22,6 +22,7 @@ coverage
# tests
packages/router-generator/tests/**/*.gen.ts
+packages/router-generator/tests/**/*.gen.js
# misc
.DS_Store
diff --git a/docs/framework/react/api/router/LinkOptionsType.md b/docs/framework/react/api/router/LinkOptionsType.md
index eb34eca806..481a5b4a3d 100644
--- a/docs/framework/react/api/router/LinkOptionsType.md
+++ b/docs/framework/react/api/router/LinkOptionsType.md
@@ -33,7 +33,7 @@ The `LinkOptions` object accepts/contains the following properties:
### `preload`
-- Type: `false | 'intent' | 'viewport'`
+- Type: `false | 'intent' | 'viewport' | 'render'`
- Optional
- If set, the link's preloading strategy will be set to this value.
- See the [Preloading guide](../../guide/preloading.md) for more information.
diff --git a/docs/framework/react/api/router/RouterEventsType.md b/docs/framework/react/api/router/RouterEventsType.md
index c4dd6e3293..f352da3109 100644
--- a/docs/framework/react/api/router/RouterEventsType.md
+++ b/docs/framework/react/api/router/RouterEventsType.md
@@ -25,6 +25,12 @@ type RouterEvents = {
toLocation: ParsedLocation
pathChanged: boolean
}
+ onBeforeRouteMount: {
+ type: 'onBeforeRouteMount'
+ fromLocation: ParsedLocation
+ toLocation: ParsedLocation
+ pathChanged: boolean
+ }
}
```
@@ -34,7 +40,7 @@ Once an event is emitted, the following properties will be present on the event
### `type` property
-- Type: `onBeforeLoad | onLoad | onResolved`
+- Type: `onBeforeLoad | onLoad | onBeforeRouteMount | onResolved`
- The type of the event
- This is useful for discriminating between events in a listener function.
diff --git a/docs/framework/react/api/router/RouterOptionsType.md b/docs/framework/react/api/router/RouterOptionsType.md
index 2b1a41f0e2..be87b6b7e3 100644
--- a/docs/framework/react/api/router/RouterOptionsType.md
+++ b/docs/framework/react/api/router/RouterOptionsType.md
@@ -46,12 +46,13 @@ The `RouterOptions` type accepts an object with the following properties and met
### `defaultPreload` property
-- Type: `undefined | false | 'intent' | 'viewport'`
+- Type: `undefined | false | 'intent' | 'viewport' | 'render'`
- Optional
- Defaults to `false`
- If `false`, routes will not be preloaded by default in any way.
- If `'intent'`, routes will be preloaded by default when the user hovers over a link or a `touchstart` event is detected on a ``.
- If `'viewport'`, routes will be preloaded by default when they are within the viewport of the browser.
+- If `'render'`, routes will be preloaded by default as soon as they are rendered in the DOM.
### `defaultPreloadDelay` property
diff --git a/docs/framework/react/api/router/RouterType.md b/docs/framework/react/api/router/RouterType.md
index 7250f3d30a..22c22d38f9 100644
--- a/docs/framework/react/api/router/RouterType.md
+++ b/docs/framework/react/api/router/RouterType.md
@@ -131,17 +131,17 @@ Navigates to a new location.
Invalidates route matches by forcing their `beforeLoad` and `load` functions to be called again.
-- Type: `(opts?: {filter?: (d: MakeRouteMatch) => boolean}) => Promise`
+- Type: `(opts?: {filter?: (d: MakeRouteMatchUnion) => boolean}) => Promise`
- This is useful any time your loader data might be out of date or stale. For example, if you have a route that displays a list of posts, and you have a loader function that fetches the list of posts from an API, you might want to invalidate the route matches for that route any time a new post is created so that the list of posts is always up-to-date.
- if `filter` is not supplied, all matches will be invalidated
- if `filter` is supplied, only matches for which `filter` returns `true` will be invalidated.
- You might also want to invalidate the Router if you imperatively `reset` the router's `CatchBoundary` to trigger loaders again.
-### `.removeCachedMatches` method
+### `.clearCache` method
Remove cached route matches.
-- Type: `(opts?: {filter?: (d: MakeRouteMatch) => boolean}) => void`
+- Type: `(opts?: {filter?: (d: MakeRouteMatchUnion) => boolean}) => void`
- if `filter` is not supplied, all cached matches will be removed
- if `filter` is supplied, only matches for which `filter` returns `true` will be removed.
diff --git a/docs/framework/react/api/router/stripSearchParamsFunction.md b/docs/framework/react/api/router/stripSearchParamsFunction.md
index 0008ccb13d..092171e0f8 100644
--- a/docs/framework/react/api/router/stripSearchParamsFunction.md
+++ b/docs/framework/react/api/router/stripSearchParamsFunction.md
@@ -7,7 +7,7 @@ title: Search middleware to strip search params
## stripSearchParams props
-The `retainSearchParams` accepts one of the following inputs:
+`stripSearchParams` accepts one of the following inputs:
- `true`: if the search schema has no required params, `true` can be used to strip all search params
- a list of keys of those search params that shall be removed; only keys of optional search params are allowed.
diff --git a/docs/framework/react/guide/code-splitting.md b/docs/framework/react/guide/code-splitting.md
index 44b2b061a3..6b3cf192d1 100644
--- a/docs/framework/react/guide/code-splitting.md
+++ b/docs/framework/react/guide/code-splitting.md
@@ -185,7 +185,7 @@ Tada! 🎉
When using the `autoCodeSplitting` feature, TanStack Router will automatically code split your route files based on the non-critical route configuration mentioned above.
> [!IMPORTANT]
-> The automatic code-splitting feature is **ONLY** available when you are using file-based routing with one of our [supported bundlers](./file-based-routing.md#prerequisites).
+> The automatic code-splitting feature is **ONLY** available when you are using file-based routing with one of our [supported bundlers](./file-based-routing.md#installation).
> This will **NOT** work if you are **only** using the CLI (`@tanstack/router-cli`).
If this is your first time using TanStack Router, then you can skip the following steps and head over to [Enabling automatic code-splitting](#enabling-automatic-code-splitting). If you've already been using TanStack Router, then you might need to make some changes to your route files to enable automatic code-splitting.
diff --git a/docs/framework/react/guide/data-loading.md b/docs/framework/react/guide/data-loading.md
index 24748a7e97..21ddc6a848 100644
--- a/docs/framework/react/guide/data-loading.md
+++ b/docs/framework/react/guide/data-loading.md
@@ -78,7 +78,7 @@ The `loader` function receives a single object with the following properties:
- `deps` - The object value returned from the `Route.loaderDeps` function. If `Route.loaderDeps` is not defined, an empty object will be provided instead.
- `location` - The current location
- `params` - The route's path params
-- `parentMatchPromise` - `Promise` or `undefined`
+- `parentMatchPromise` - `Promise` (`undefined` for the root route)
- `preload` - Boolean which is `true` when the route is being preloaded instead of loaded
- `route` - The route itself
diff --git a/docs/framework/react/guide/file-based-routing.md b/docs/framework/react/guide/file-based-routing.md
index acee06f2a4..bfd64939c3 100644
--- a/docs/framework/react/guide/file-based-routing.md
+++ b/docs/framework/react/guide/file-based-routing.md
@@ -4,6 +4,9 @@ title: File-Based Routing
Most of the TanStack Router documentation is written for file-based routing and is intended to help you understand in more detail how to configure file-based routing and the technical details behind how it works. While file-based routing is the preferred and recommended way to configure TanStack Router, you can also use [code-based routing](./code-based-routing.md) if you prefer.
+> [!NOTE]
+> 🧠If you are already familiar with how file-based routing works and are looking for setup instructions, you can skip ahead to the [Installation](#installation) section. Or if you looking for the configuration options, skip ahead to the [Options](#options) section.
+
## What is File-Based Routing?
File-based routing is a way to configure your routes using the filesystem. Instead of defining your route structure via code, you can define your routes using a series of files and directories that represent the route hierarchy of your application. This brings a number of benefits:
@@ -143,23 +146,21 @@ File-based routing requires that you follow a few simple file naming conventions
- **`.lazy.tsx` File Type**
- The `lazy` suffix can be used to code-split components for a route. For example, `blog.post.lazy.tsx` will be used as the component for the `blog.post` route.
-## Prerequisites
+## Installation
+
+To get started with file-based routing, you'll need to configure your project's bundler to use the TanStack Router Plugin or the TanStack Router CLI.
To enable file-based routing, you'll need to be using React with a supported bundler. TanStack Router currently has support for the following bundlers:
-- Vite
-- Rspack/Rsbuild
-- Webpack
-- Esbuild
+- [Vite](#configuration-with-vite)
+- [Rspack/Rsbuild](#configuration-with-rspackrsbuild)
+- [Webpack](#configuration-with-webpack)
+- [Esbuild](#configuration-with-esbuild)
- Others??? (let us know if you'd like to see support for a specific bundler)
-If your bundler is not yet supported, you can reach out to us on Discord or GitHub to let us know. Till then, fear not! You can still use the [`@tanstack/router-cli`](#configuration-with-the-tanstack-router-cli) package to generate your route tree file.
-
-## Installation
-
-To get started with file-based routing, you'll need to configure your project's bundler to use the TanStack Router Plugin or the TanStack Router CLI.
+When using using TanStack Router's file-based routing through one of the supported bundlers, our plugin will **automatically generate your route configuration through your bundler's dev and build processes**. It is the easiest way to use TanStack Router's route generation features.
-If you are using TanStack Router's file-based routing through a bundler, the plugin will **automatically generate your route configuration through your bundler's dev and build processes**. It is the easiest way to use TanStack Router's route generation features.
+If your bundler is not yet supported, you can reach out to us on Discord or GitHub to let us know. Till then, fear not! You can still use the [`@tanstack/router-cli`](#configuration-with-the-tanstack-router-cli) package to generate your route tree file.
### Configuration with Vite
@@ -192,6 +193,10 @@ Or, you can clone our [Quickstart Vite example](https://github.com/TanStack/rout
> [!WARNING]
> If you are using the older `@tanstack/router-vite-plugin` package, you can still continue to use it, as it will be aliased to the `@tanstack/router-plugin/vite` package. However, we would recommend using the `@tanstack/router-plugin` package directly.
+Now that you've added the plugin to your Vite configuration, you're all set to start using file-based routing with TanStack Router.
+
+You shouldn't forget to _ignore_ the generated route tree file. Head over to the [Ignoring the generated route tree file](#ignoring-the-generated-route-tree-file) section to learn more.
+
### Configuration with Rspack/Rsbuild
To use file-based routing with **Rspack** or **Rsbuild**, you'll need to install the `@tanstack/router-plugin` package.
@@ -220,6 +225,10 @@ export default defineConfig({
Or, you can clone our [Quickstart Rspack/Rsbuild example](https://github.com/TanStack/router/tree/main/examples/react/quickstart-rspack-file-based) and get started.
+Now that you've added the plugin to your Rspack/Rsbuild configuration, you're all set to start using file-based routing with TanStack Router.
+
+You shouldn't forget to _ignore_ the generated route tree file. Head over to the [Ignoring the generated route tree file](#ignoring-the-generated-route-tree-file) section to learn more.
+
### Configuration with Webpack
To use file-based routing with **Webpack**, you'll need to install the `@tanstack/router-plugin` package.
@@ -241,6 +250,10 @@ export default {
Or, you can clone our [Quickstart Webpack example](https://github.com/TanStack/router/tree/main/examples/react/quickstart-webpack-file-based) and get started.
+Now that you've added the plugin to your Webpack configuration, you're all set to start using file-based routing with TanStack Router.
+
+You shouldn't forget to _ignore_ the generated route tree file. Head over to the [Ignoring the generated route tree file](#ignoring-the-generated-route-tree-file) section to learn more.
+
### Configuration with Esbuild
To use file-based routing with **Esbuild**, you'll need to install the `@tanstack/router-plugin` package.
@@ -263,6 +276,10 @@ export default {
Or, you can clone our [Quickstart Esbuild example](https://github.com/TanStack/router/tree/main/examples/react/quickstart-esbuild-file-based) and get started.
+Now that you've added the plugin to your Esbuild configuration, you're all set to start using file-based routing with TanStack Router.
+
+You shouldn't forget to _ignore_ the generated route tree file. Head over to the [Ignoring the generated route tree file](#ignoring-the-generated-route-tree-file) section to learn more.
+
### Configuration with the TanStack Router CLI
To use file-based routing with the TanStack Router CLI, you'll need to install the `@tanstack/router-cli` package.
@@ -284,6 +301,8 @@ Once installed, you'll need to amend your your scripts in your `package.json` fo
}
```
+You shouldn't forget to _ignore_ the generated route tree file. Head over to the [Ignoring the generated route tree file](#ignoring-the-generated-route-tree-file) section to learn more.
+
With the CLI installed, the following commands are made available via the `tsr` command
#### Using the `generate` command
@@ -329,6 +348,26 @@ export default defineConfig({
})
```
+### Ignoring the generated route tree file
+
+If your project is configured to use a linter and/or formatter, you may want to ignore the generated route tree file. This is this file is managed by TanStack Router and shouldn't and therefore shouldn't be changed by your linter or formatter.
+
+Here are some resources to help you ignore the generated route tree file:
+
+- Prettier - [https://prettier.io/docs/en/ignore.html#ignoring-files-prettierignore](https://prettier.io/docs/en/ignore.html#ignoring-files-prettierignore)
+- ESLint - [https://eslint.org/docs/latest/use/configure/ignore#ignoring-files](https://eslint.org/docs/latest/use/configure/ignore#ignoring-files)
+- Biome - [https://biomejs.dev/reference/configuration/#filesignore](https://biomejs.dev/reference/configuration/#filesignore)
+
+If you are using VSCode, you can also add the following to your `.vscode/settings.json` file to exclude the generated route tree file from the editor's file watcher:
+
+```json
+{
+ "files.watcherExclude": {
+ "**/routeTree.gen.ts": true
+ }
+}
+```
+
## Configuration
File-based routing comes with some sane defaults that should work for most projects:
@@ -394,7 +433,6 @@ The following options are available for configuration via the `tsr.config.json`
- Default:
- ```
[
- '/* prettier-ignore-start */',
'/* eslint-disable */',
'// @ts-nocheck',
'// noinspection JSUnusedGlobalSymbols'
@@ -403,13 +441,8 @@ The following options are available for configuration via the `tsr.config.json`
- **`routeTreeFileFooter`**
- (Optional) An array of strings to append to the generated route tree file content.
- - Default:
- - ```
- [
- '/* prettier-ignore-end */'
- ]
- ```
-- **`disableManifestGeneration**
+ - Default: `[]`
+- **`disableManifestGeneration`**
- (Optional, **Defaults to `false`**) disables generating the route tree manifest
## Route Inclusion / Exclusion
diff --git a/docs/framework/react/guide/preloading.md b/docs/framework/react/guide/preloading.md
index ca1c820dba..c3221e0208 100644
--- a/docs/framework/react/guide/preloading.md
+++ b/docs/framework/react/guide/preloading.md
@@ -13,7 +13,8 @@ Preloading in TanStack Router is a way to load a route before the user actually
- Preloading by **"viewport**" works by using the Intersection Observer API to preload the dependencies for the destination route when the `` component is in the viewport.
- This strategy is useful for preloading routes that are below the fold or off-screen.
- Render
- - **Coming soon!**
+ - Preloading by **"render"** works by preloading the dependencies for the destination route as soon as the `` component is rendered in the DOM.
+ - This strategy is useful for preloading routes that are always needed.
## How long does preloaded data stay in memory?
diff --git a/docs/framework/react/guide/search-params.md b/docs/framework/react/guide/search-params.md
index 62c29af6e2..08a21e4b1d 100644
--- a/docs/framework/react/guide/search-params.md
+++ b/docs/framework/react/guide/search-params.md
@@ -302,7 +302,6 @@ export const Route = createFileRoute('/shop/products/')({
When using [ArkType](https://arktype.io/) an adapter is not needed to ensure the correct `input` and `output` types are used for navigation and reading search params. This is because [ArkType](https://arktype.io/) implements [Standard Schema](https://github.com/standard-schema/standard-schema)
```tsx
-import { arkTypeSearchValidator } from '@tanstack/router-arktype-adapter'
import { createFileRoute } from '@tanstack/react-router'
import { type } from 'arktype'
diff --git a/docs/framework/react/migrate-from-react-location.md b/docs/framework/react/migrate-from-react-location.md
index 76bd554704..ea0f1c4035 100644
--- a/docs/framework/react/migrate-from-react-location.md
+++ b/docs/framework/react/migrate-from-react-location.md
@@ -57,7 +57,7 @@ export default defineConfig({
})
```
-However, if your application does not use Vite, you use one of our other [supported bundlers](./guide/file-based-routing.md#prerequisites), or you can use the `@tanstack/router-cli` package to watch for changes in your routes files and automatically update the routes configuration.
+However, if your application does not use Vite, you use one of our other [supported bundlers](./guide/file-based-routing.md#installation), or you can use the `@tanstack/router-cli` package to watch for changes in your routes files and automatically update the routes configuration.
### Step 3: Add the file-based configuration file to your project
diff --git a/docs/framework/react/start/getting-started.md b/docs/framework/react/start/getting-started.md
index 1baab5d7b6..91d4185767 100644
--- a/docs/framework/react/start/getting-started.md
+++ b/docs/framework/react/start/getting-started.md
@@ -53,7 +53,7 @@ npm i @tanstack/start @tanstack/react-router vinxi
You'll also need React and the Vite React plugin, so install them too:
```shell
-npm i react react-dom @vitejs/plugin-react
+npm i react react-dom; npm i -D @vitejs/plugin-react
```
and some TypeScript:
@@ -66,15 +66,15 @@ npm i -D typescript @types/react @types/react-dom
We'll then update our `package.json` to reference the new Vinxi entry point and set `"type": "module"`:
-```jsonc
+```json
{
// ...
"type": "module",
"scripts": {
"dev": "vinxi dev",
"build": "vinxi build",
- "start": "vinxi start",
- },
+ "start": "vinxi start"
+ }
}
```
@@ -195,10 +195,13 @@ Finally, we need to create the root of our application. This is the entry point
```tsx
// app/routes/__root.tsx
-import { createRootRoute } from '@tanstack/react-router'
-import { Outlet, ScrollRestoration } from '@tanstack/react-router'
+import {
+ Outlet,
+ ScrollRestoration,
+ createRootRoute,
+} from '@tanstack/react-router'
import { Body, Head, Html, Meta, Scripts } from '@tanstack/start'
-import * as React from 'react'
+import type { ReactNode } from 'react'
export const Route = createRootRoute({
head: () => ({
@@ -226,7 +229,7 @@ function RootComponent() {
)
}
-function RootDocument({ children }: { children: React.ReactNode }) {
+function RootDocument({ children }: Readonly<{ children: ReactNode }>) {
return (
diff --git a/docs/framework/react/start/overview.md b/docs/framework/react/start/overview.md
index d606a5d461..85c54710ac 100644
--- a/docs/framework/react/start/overview.md
+++ b/docs/framework/react/start/overview.md
@@ -89,9 +89,9 @@ TanStack works closely with our partners to provide the best possible developer
- **Convex**
A serverless database platform that integrates seamlessly with TanStack Start. Convex is designed to simplify the process of managing your application's data and provides a real-time, scalable, and transactional data backend that works well with TanStack Start applications. Convex also collaborates closely with the TanStack team to ensure that TanStack Start provides APIs that are up to date with the latest in database best practices.
diff --git a/e2e/react-router/basic-esbuild-file-based/package.json b/e2e/react-router/basic-esbuild-file-based/package.json
index 0faedcd892..ebc7a9a2b7 100644
--- a/e2e/react-router/basic-esbuild-file-based/package.json
+++ b/e2e/react-router/basic-esbuild-file-based/package.json
@@ -20,9 +20,9 @@
"zod": "^3.23.8"
},
"devDependencies": {
- "@playwright/test": "^1.48.0",
+ "@playwright/test": "^1.48.2",
"@types/react": "^18.2.47",
"@types/react-dom": "^18.2.18",
- "esbuild": "^0.23.1"
+ "esbuild": "^0.24.0"
}
}
diff --git a/e2e/react-router/basic-file-based-code-splitting/package.json b/e2e/react-router/basic-file-based-code-splitting/package.json
index 0c72e5f608..7079d913e6 100644
--- a/e2e/react-router/basic-file-based-code-splitting/package.json
+++ b/e2e/react-router/basic-file-based-code-splitting/package.json
@@ -18,10 +18,10 @@
"zod": "^3.23.8"
},
"devDependencies": {
- "@playwright/test": "^1.48.1",
+ "@playwright/test": "^1.48.2",
"@types/react": "^18.2.47",
"@types/react-dom": "^18.2.18",
"@vitejs/plugin-react": "^4.3.3",
- "vite": "^5.4.9"
+ "vite": "^5.4.10"
}
}
diff --git a/e2e/react-router/basic-file-based-code-splitting/src/routeTree.gen.ts b/e2e/react-router/basic-file-based-code-splitting/src/routeTree.gen.ts
index 5337c872c7..f25ea3198a 100644
--- a/e2e/react-router/basic-file-based-code-splitting/src/routeTree.gen.ts
+++ b/e2e/react-router/basic-file-based-code-splitting/src/routeTree.gen.ts
@@ -1,12 +1,12 @@
-/* prettier-ignore-start */
-
/* eslint-disable */
// @ts-nocheck
// noinspection JSUnusedGlobalSymbols
-// This file is auto-generated by TanStack Router
+// This file was automatically generated by TanStack Router.
+// You should NOT make any changes in this file as it will be overwritten.
+// Additionally, you should also exclude this file from your linter and/or formatter to prevent it from being checked or modified.
// Import Routes
@@ -270,8 +270,6 @@ export const routeTree = rootRoute
._addFileChildren(rootRouteChildren)
._addFileTypes()
-/* prettier-ignore-end */
-
/* ROUTE_MANIFEST_START
{
"routes": {
diff --git a/e2e/react-router/basic-file-based/package.json b/e2e/react-router/basic-file-based/package.json
index d0f5c7cdd1..8a6b8e2613 100644
--- a/e2e/react-router/basic-file-based/package.json
+++ b/e2e/react-router/basic-file-based/package.json
@@ -20,10 +20,10 @@
"zod": "^3.23.8"
},
"devDependencies": {
- "@playwright/test": "^1.48.1",
+ "@playwright/test": "^1.48.2",
"@types/react": "^18.2.47",
"@types/react-dom": "^18.2.18",
"@vitejs/plugin-react": "^4.3.3",
- "vite": "^5.4.9"
+ "vite": "^5.4.10"
}
}
diff --git a/e2e/react-router/basic-file-based/src/routeTree.gen.ts b/e2e/react-router/basic-file-based/src/routeTree.gen.ts
index 48ff05cc25..9795d4e1b3 100644
--- a/e2e/react-router/basic-file-based/src/routeTree.gen.ts
+++ b/e2e/react-router/basic-file-based/src/routeTree.gen.ts
@@ -1,12 +1,12 @@
-/* prettier-ignore-start */
-
/* eslint-disable */
// @ts-nocheck
// noinspection JSUnusedGlobalSymbols
-// This file is auto-generated by TanStack Router
+// This file was automatically generated by TanStack Router.
+// You should NOT make any changes in this file as it will be overwritten.
+// Additionally, you should also exclude this file from your linter and/or formatter to prevent it from being checked or modified.
import { createFileRoute } from '@tanstack/react-router'
@@ -440,8 +440,6 @@ export const routeTree = rootRoute
._addFileChildren(rootRouteChildren)
._addFileTypes()
-/* prettier-ignore-end */
-
/* ROUTE_MANIFEST_START
{
"routes": {
diff --git a/e2e/react-router/basic-react-query-file-based/package.json b/e2e/react-router/basic-react-query-file-based/package.json
index 06c00b351a..166794aeb5 100644
--- a/e2e/react-router/basic-react-query-file-based/package.json
+++ b/e2e/react-router/basic-react-query-file-based/package.json
@@ -10,8 +10,8 @@
"test:e2e": "playwright test --project=chromium"
},
"dependencies": {
- "@tanstack/react-query": "^5.59.15",
- "@tanstack/react-query-devtools": "^5.59.15",
+ "@tanstack/react-query": "^5.59.16",
+ "@tanstack/react-query-devtools": "^5.59.16",
"@tanstack/react-router": "workspace:^",
"@tanstack/router-devtools": "workspace:^",
"@tanstack/router-plugin": "workspace:^",
@@ -21,10 +21,10 @@
"zod": "^3.23.8"
},
"devDependencies": {
- "@playwright/test": "^1.48.1",
+ "@playwright/test": "^1.48.2",
"@types/react": "^18.2.47",
"@types/react-dom": "^18.2.18",
"@vitejs/plugin-react": "^4.3.3",
- "vite": "^5.4.9"
+ "vite": "^5.4.10"
}
}
diff --git a/e2e/react-router/basic-react-query-file-based/src/routeTree.gen.ts b/e2e/react-router/basic-react-query-file-based/src/routeTree.gen.ts
index 206cf74ee4..375fe8dc91 100644
--- a/e2e/react-router/basic-react-query-file-based/src/routeTree.gen.ts
+++ b/e2e/react-router/basic-react-query-file-based/src/routeTree.gen.ts
@@ -1,12 +1,12 @@
-/* prettier-ignore-start */
-
/* eslint-disable */
// @ts-nocheck
// noinspection JSUnusedGlobalSymbols
-// This file is auto-generated by TanStack Router
+// This file was automatically generated by TanStack Router.
+// You should NOT make any changes in this file as it will be overwritten.
+// Additionally, you should also exclude this file from your linter and/or formatter to prevent it from being checked or modified.
// Import Routes
@@ -242,8 +242,6 @@ export const routeTree = rootRoute
._addFileChildren(rootRouteChildren)
._addFileTypes()
-/* prettier-ignore-end */
-
/* ROUTE_MANIFEST_START
{
"routes": {
diff --git a/e2e/react-router/basic-react-query/package.json b/e2e/react-router/basic-react-query/package.json
index d7293f294a..729bc85d1f 100644
--- a/e2e/react-router/basic-react-query/package.json
+++ b/e2e/react-router/basic-react-query/package.json
@@ -10,8 +10,8 @@
"test:e2e": "playwright test --project=chromium"
},
"dependencies": {
- "@tanstack/react-query": "^5.59.15",
- "@tanstack/react-query-devtools": "^5.59.15",
+ "@tanstack/react-query": "^5.59.16",
+ "@tanstack/react-query-devtools": "^5.59.16",
"@tanstack/react-router": "workspace:^",
"@tanstack/router-devtools": "workspace:^",
"react": "^18.2.0",
@@ -19,10 +19,10 @@
"redaxios": "^0.5.1"
},
"devDependencies": {
- "@playwright/test": "^1.48.1",
+ "@playwright/test": "^1.48.2",
"@types/react": "^18.2.47",
"@types/react-dom": "^18.2.18",
"@vitejs/plugin-react": "^4.3.3",
- "vite": "^5.4.9"
+ "vite": "^5.4.10"
}
}
diff --git a/e2e/react-router/basic-scroll-restoration/.gitignore b/e2e/react-router/basic-scroll-restoration/.gitignore
new file mode 100644
index 0000000000..8354e4d50d
--- /dev/null
+++ b/e2e/react-router/basic-scroll-restoration/.gitignore
@@ -0,0 +1,10 @@
+node_modules
+.DS_Store
+dist
+dist-ssr
+*.local
+
+/test-results/
+/playwright-report/
+/blob-report/
+/playwright/.cache/
\ No newline at end of file
diff --git a/e2e/react-router/basic-scroll-restoration/index.html b/e2e/react-router/basic-scroll-restoration/index.html
new file mode 100644
index 0000000000..a4b3349437
--- /dev/null
+++ b/e2e/react-router/basic-scroll-restoration/index.html
@@ -0,0 +1,24 @@
+
+
+
+
+
+ Vite App
+
+
+
+
+
+
+
+
diff --git a/e2e/react-router/basic-scroll-restoration/package.json b/e2e/react-router/basic-scroll-restoration/package.json
new file mode 100644
index 0000000000..bce8634dc4
--- /dev/null
+++ b/e2e/react-router/basic-scroll-restoration/package.json
@@ -0,0 +1,27 @@
+{
+ "name": "tanstack-router-e2e-react-basic-scroll-restoration",
+ "private": true,
+ "type": "module",
+ "scripts": {
+ "dev": "vite --port=3001",
+ "build": "vite build && tsc --noEmit",
+ "serve": "vite preview",
+ "start": "vite",
+ "test:e2e": "playwright test --project=chromium"
+ },
+ "dependencies": {
+ "@tanstack/react-router": "workspace:^",
+ "@tanstack/router-devtools": "workspace:^",
+ "@tanstack/react-virtual": "^3.10.8",
+ "react": "^18.2.0",
+ "react-dom": "^18.2.0",
+ "redaxios": "^0.5.1"
+ },
+ "devDependencies": {
+ "@playwright/test": "^1.48.2",
+ "@types/react": "^18.2.47",
+ "@types/react-dom": "^18.2.18",
+ "@vitejs/plugin-react": "^4.3.3",
+ "vite": "^5.4.10"
+ }
+}
diff --git a/e2e/react-router/basic-scroll-restoration/playwright.config.ts b/e2e/react-router/basic-scroll-restoration/playwright.config.ts
new file mode 100644
index 0000000000..f83eacf129
--- /dev/null
+++ b/e2e/react-router/basic-scroll-restoration/playwright.config.ts
@@ -0,0 +1,29 @@
+import { defineConfig, devices } from '@playwright/test'
+
+/**
+ * See https://playwright.dev/docs/test-configuration.
+ */
+export default defineConfig({
+ testDir: './tests',
+
+ reporter: [['line']],
+
+ use: {
+ /* Base URL to use in actions like `await page.goto('/')`. */
+ baseURL: 'http://localhost:3001/',
+ },
+
+ webServer: {
+ command: 'pnpm run dev',
+ url: 'http://localhost:3001',
+ reuseExistingServer: !process.env.CI,
+ stdout: 'pipe',
+ },
+
+ projects: [
+ {
+ name: 'chromium',
+ use: { ...devices['Desktop Chrome'] },
+ },
+ ],
+})
diff --git a/e2e/react-router/basic-scroll-restoration/src/has-shown.tsx b/e2e/react-router/basic-scroll-restoration/src/has-shown.tsx
new file mode 100644
index 0000000000..f6a0bdbee9
--- /dev/null
+++ b/e2e/react-router/basic-scroll-restoration/src/has-shown.tsx
@@ -0,0 +1,48 @@
+import { useEffect, useLayoutEffect, useRef, useState } from 'react'
+
+const HasShown = ({ id }: { id: string }) => {
+ const [hasShown, setHasShown] = useState(false)
+ const elementRef = useRef(null)
+
+ const [visible, setVisible] = useState(false)
+
+ useLayoutEffect(() => {
+ const observer = new IntersectionObserver(([entry]) => {
+ if (!hasShown && entry.isIntersecting) {
+ setHasShown(true)
+ }
+ })
+
+ const currentRef = elementRef.current
+ if (currentRef) {
+ observer.observe(currentRef)
+ }
+
+ return () => {
+ if (currentRef) {
+ observer.unobserve(currentRef)
+ }
+ }
+ }, [hasShown])
+
+ useEffect(() => {
+ const timer = setTimeout(() => {
+ setVisible(true)
+ }, 100)
+
+ return () => {
+ clearTimeout(timer)
+ }
+ }, [])
+
+ return (
+
+ )
+}
+
+const byElementRoute = createRoute({
+ getParentRoute: () => rootRoute,
+ path: '/by-element',
+ loader: () => new Promise((r) => setTimeout(r, 500)),
+ component: ByElementComponent,
+})
+
+function ByElementComponent() {
+ // We need a unique ID for manual scroll restoration on a specific element
+ // It should be as unique as possible for this element across your app
+ const scrollRestorationId = 'myVirtualizedContent'
+
+ // We use that ID to get the scroll entry for this element
+ const scrollEntry = useElementScrollRestoration({
+ id: scrollRestorationId,
+ })
+
+ // Let's use TanStack Virtual to virtualize some content!
+ const virtualizerParentRef = React.useRef(null)
+ const virtualizer = useVirtualizer({
+ count: 10000,
+ getScrollElement: () => virtualizerParentRef.current,
+ estimateSize: () => 100,
+ // We pass the scrollY from the scroll restoration entry to the virtualizer
+ // as the initial offset
+ initialOffset: scrollEntry?.scrollY,
+ })
+
+ return (
+
+
+
+ )
+}
diff --git a/packages/router-generator/tests/generator/custom-scaffolding/snapshot/api/bar.tsx b/packages/router-generator/tests/generator/custom-scaffolding/snapshot/api/bar.tsx
new file mode 100644
index 0000000000..751d4e4061
--- /dev/null
+++ b/packages/router-generator/tests/generator/custom-scaffolding/snapshot/api/bar.tsx
@@ -0,0 +1,8 @@
+import { json } from '@tanstack/start'
+import { createAPIFileRoute } from '@tanstack/start/api'
+
+export const Route = createAPIFileRoute('/api/bar')({
+ GET: ({ request, params }) => {
+ return json({ message: 'Hello /api/test' })
+ },
+})
diff --git a/packages/router-generator/tests/generator/custom-scaffolding/snapshot/foo.lazy.tsx b/packages/router-generator/tests/generator/custom-scaffolding/snapshot/foo.lazy.tsx
new file mode 100644
index 0000000000..515193584e
--- /dev/null
+++ b/packages/router-generator/tests/generator/custom-scaffolding/snapshot/foo.lazy.tsx
@@ -0,0 +1,10 @@
+import * as React from 'react'
+import { createLazyFileRoute } from '@tanstack/react-router'
+
+export const Route = createLazyFileRoute('/foo')({
+ component: RouteComponent,
+})
+
+function RouteComponent() {
+ return 'Hello /foo!'
+}
diff --git a/packages/router-generator/tests/generator/custom-scaffolding/snapshot/index.tsx b/packages/router-generator/tests/generator/custom-scaffolding/snapshot/index.tsx
new file mode 100644
index 0000000000..8b22ea6bb5
--- /dev/null
+++ b/packages/router-generator/tests/generator/custom-scaffolding/snapshot/index.tsx
@@ -0,0 +1,10 @@
+import * as React from 'react'
+import { createFileRoute } from '@tanstack/react-router'
+
+export const Route = createFileRoute('/')({
+ component: RouteComponent,
+})
+
+function RouteComponent() {
+ return 'Hello /!'
+}
diff --git a/packages/router-generator/tests/generator/custom-tokens/routeTree.snapshot.ts b/packages/router-generator/tests/generator/custom-tokens/routeTree.snapshot.ts
index 4ac0690d3a..a9170a93ef 100644
--- a/packages/router-generator/tests/generator/custom-tokens/routeTree.snapshot.ts
+++ b/packages/router-generator/tests/generator/custom-tokens/routeTree.snapshot.ts
@@ -1,12 +1,12 @@
-/* prettier-ignore-start */
-
/* eslint-disable */
// @ts-nocheck
// noinspection JSUnusedGlobalSymbols
-// This file is auto-generated by TanStack Router
+// This file was automatically generated by TanStack Router.
+// You should NOT make any changes in this file as it will be overwritten.
+// Additionally, you should also exclude this file from your linter and/or formatter to prevent it from being checked or modified.
// Import Routes
@@ -245,8 +245,6 @@ export const routeTree = rootRoute
._addFileChildren(rootRouteChildren)
._addFileTypes()
-/* prettier-ignore-end */
-
/* ROUTE_MANIFEST_START
{
"routes": {
diff --git a/packages/router-generator/tests/generator/file-modification/routeTree.snapshot.ts b/packages/router-generator/tests/generator/file-modification/routeTree.snapshot.ts
index 44ef3c1039..f42e1f086f 100644
--- a/packages/router-generator/tests/generator/file-modification/routeTree.snapshot.ts
+++ b/packages/router-generator/tests/generator/file-modification/routeTree.snapshot.ts
@@ -1,12 +1,12 @@
-/* prettier-ignore-start */
-
/* eslint-disable */
// @ts-nocheck
// noinspection JSUnusedGlobalSymbols
-// This file is auto-generated by TanStack Router
+// This file was automatically generated by TanStack Router.
+// You should NOT make any changes in this file as it will be overwritten.
+// Additionally, you should also exclude this file from your linter and/or formatter to prevent it from being checked or modified.
import { createFileRoute } from '@tanstack/react-router'
@@ -144,8 +144,6 @@ export const routeTree = rootRoute
._addFileChildren(rootRouteChildren)
._addFileTypes()
-/* prettier-ignore-end */
-
/* ROUTE_MANIFEST_START
{
"routes": {
diff --git a/packages/router-generator/tests/generator/flat/routeTree.snapshot.ts b/packages/router-generator/tests/generator/flat/routeTree.snapshot.ts
index 62f1e62154..50840b912e 100644
--- a/packages/router-generator/tests/generator/flat/routeTree.snapshot.ts
+++ b/packages/router-generator/tests/generator/flat/routeTree.snapshot.ts
@@ -1,12 +1,12 @@
-/* prettier-ignore-start */
-
/* eslint-disable */
// @ts-nocheck
// noinspection JSUnusedGlobalSymbols
-// This file is auto-generated by TanStack Router
+// This file was automatically generated by TanStack Router.
+// You should NOT make any changes in this file as it will be overwritten.
+// Additionally, you should also exclude this file from your linter and/or formatter to prevent it from being checked or modified.
// Import Routes
@@ -267,8 +267,6 @@ export const routeTree = rootRoute
._addFileChildren(rootRouteChildren)
._addFileTypes()
-/* prettier-ignore-end */
-
/* ROUTE_MANIFEST_START
{
"routes": {
diff --git a/packages/router-generator/tests/generator/nested-layouts/routeTree.snapshot.ts b/packages/router-generator/tests/generator/nested-layouts/routeTree.snapshot.ts
index 62b079309a..9137e82914 100644
--- a/packages/router-generator/tests/generator/nested-layouts/routeTree.snapshot.ts
+++ b/packages/router-generator/tests/generator/nested-layouts/routeTree.snapshot.ts
@@ -1,12 +1,12 @@
-/* prettier-ignore-start */
-
/* eslint-disable */
// @ts-nocheck
// noinspection JSUnusedGlobalSymbols
-// This file is auto-generated by TanStack Router
+// This file was automatically generated by TanStack Router.
+// You should NOT make any changes in this file as it will be overwritten.
+// Additionally, you should also exclude this file from your linter and/or formatter to prevent it from being checked or modified.
import { createFileRoute } from '@tanstack/react-router'
@@ -677,8 +677,6 @@ export const routeTree = rootRoute
._addFileChildren(rootRouteChildren)
._addFileTypes()
-/* prettier-ignore-end */
-
/* ROUTE_MANIFEST_START
{
"routes": {
diff --git a/packages/router-generator/tests/generator/nested/routeTree.snapshot.ts b/packages/router-generator/tests/generator/nested/routeTree.snapshot.ts
index d3332f1da6..49498ae411 100644
--- a/packages/router-generator/tests/generator/nested/routeTree.snapshot.ts
+++ b/packages/router-generator/tests/generator/nested/routeTree.snapshot.ts
@@ -1,12 +1,12 @@
-/* prettier-ignore-start */
-
/* eslint-disable */
// @ts-nocheck
// noinspection JSUnusedGlobalSymbols
-// This file is auto-generated by TanStack Router
+// This file was automatically generated by TanStack Router.
+// You should NOT make any changes in this file as it will be overwritten.
+// Additionally, you should also exclude this file from your linter and/or formatter to prevent it from being checked or modified.
// Import Routes
@@ -267,8 +267,6 @@ export const routeTree = rootRoute
._addFileChildren(rootRouteChildren)
._addFileTypes()
-/* prettier-ignore-end */
-
/* ROUTE_MANIFEST_START
{
"routes": {
diff --git a/packages/router-generator/tests/generator/no-manifest/routeTree.snapshot.ts b/packages/router-generator/tests/generator/no-manifest/routeTree.snapshot.ts
index bba4811b4a..8f3a052d06 100644
--- a/packages/router-generator/tests/generator/no-manifest/routeTree.snapshot.ts
+++ b/packages/router-generator/tests/generator/no-manifest/routeTree.snapshot.ts
@@ -1,12 +1,12 @@
-/* prettier-ignore-start */
-
/* eslint-disable */
// @ts-nocheck
// noinspection JSUnusedGlobalSymbols
-// This file is auto-generated by TanStack Router
+// This file was automatically generated by TanStack Router.
+// You should NOT make any changes in this file as it will be overwritten.
+// Additionally, you should also exclude this file from your linter and/or formatter to prevent it from being checked or modified.
// Import Routes
@@ -70,5 +70,3 @@ const rootRouteChildren: RootRouteChildren = {
export const routeTree = rootRoute
._addFileChildren(rootRouteChildren)
._addFileTypes()
-
-/* prettier-ignore-end */
diff --git a/packages/router-generator/tests/generator/only-root/routeTree.snapshot.ts b/packages/router-generator/tests/generator/only-root/routeTree.snapshot.ts
index a65ec67d05..78c694471a 100644
--- a/packages/router-generator/tests/generator/only-root/routeTree.snapshot.ts
+++ b/packages/router-generator/tests/generator/only-root/routeTree.snapshot.ts
@@ -1,12 +1,12 @@
-/* prettier-ignore-start */
-
/* eslint-disable */
// @ts-nocheck
// noinspection JSUnusedGlobalSymbols
-// This file is auto-generated by TanStack Router
+// This file was automatically generated by TanStack Router.
+// You should NOT make any changes in this file as it will be overwritten.
+// Additionally, you should also exclude this file from your linter and/or formatter to prevent it from being checked or modified.
// Import Routes
@@ -47,8 +47,6 @@ export const routeTree = rootRoute
._addFileChildren(rootRouteChildren)
._addFileTypes()
-/* prettier-ignore-end */
-
/* ROUTE_MANIFEST_START
{
"routes": {
diff --git a/packages/router-generator/tests/generator/route-groups/routeTree.snapshot.ts b/packages/router-generator/tests/generator/route-groups/routeTree.snapshot.ts
index 4dae2df29a..57a9e6aa8c 100644
--- a/packages/router-generator/tests/generator/route-groups/routeTree.snapshot.ts
+++ b/packages/router-generator/tests/generator/route-groups/routeTree.snapshot.ts
@@ -1,12 +1,12 @@
-/* prettier-ignore-start */
-
/* eslint-disable */
// @ts-nocheck
// noinspection JSUnusedGlobalSymbols
-// This file is auto-generated by TanStack Router
+// This file was automatically generated by TanStack Router.
+// You should NOT make any changes in this file as it will be overwritten.
+// Additionally, you should also exclude this file from your linter and/or formatter to prevent it from being checked or modified.
import { createFileRoute } from '@tanstack/react-router'
@@ -292,8 +292,6 @@ export const routeTree = rootRoute
._addFileChildren(rootRouteChildren)
._addFileTypes()
-/* prettier-ignore-end */
-
/* ROUTE_MANIFEST_START
{
"routes": {
diff --git a/packages/router-generator/tests/generator/single-level/routeTree.snapshot.ts b/packages/router-generator/tests/generator/single-level/routeTree.snapshot.ts
index c7fd89688b..2f69793c10 100644
--- a/packages/router-generator/tests/generator/single-level/routeTree.snapshot.ts
+++ b/packages/router-generator/tests/generator/single-level/routeTree.snapshot.ts
@@ -1,12 +1,12 @@
-/* prettier-ignore-start */
-
/* eslint-disable */
// @ts-nocheck
// noinspection JSUnusedGlobalSymbols
-// This file is auto-generated by TanStack Router
+// This file was automatically generated by TanStack Router.
+// You should NOT make any changes in this file as it will be overwritten.
+// Additionally, you should also exclude this file from your linter and/or formatter to prevent it from being checked or modified.
// Import Routes
@@ -90,8 +90,6 @@ export const routeTree = rootRoute
._addFileChildren(rootRouteChildren)
._addFileTypes()
-/* prettier-ignore-end */
-
/* ROUTE_MANIFEST_START
{
"routes": {
diff --git a/packages/router-generator/tests/generator/types-disabled/routeTree.gen.js b/packages/router-generator/tests/generator/types-disabled/routeTree.gen.js
deleted file mode 100644
index 374efaa2fa..0000000000
--- a/packages/router-generator/tests/generator/types-disabled/routeTree.gen.js
+++ /dev/null
@@ -1,92 +0,0 @@
-/* prettier-ignore-start */
-
-/* eslint-disable */
-
-// @ts-nocheck
-
-// noinspection JSUnusedGlobalSymbols
-
-// This file is auto-generated by TanStack Router
-
-// Import Routes
-
-import { Route as rootRoute } from './routes/__root'
-import { Route as PostsImport } from './routes/posts'
-import { Route as IndexImport } from './routes/index'
-import { Route as UsersUserIdImport } from './routes/users.$userId'
-import { Route as PostsPostIdImport } from './routes/posts/$postId'
-
-// Create/Update Routes
-
-const PostsRoute = PostsImport.update({
- id: '/posts',
- path: '/posts',
- getParentRoute: () => rootRoute,
-})
-
-const IndexRoute = IndexImport.update({
- id: '/',
- path: '/',
- getParentRoute: () => rootRoute,
-})
-
-const UsersUserIdRoute = UsersUserIdImport.update({
- id: '/users/$userId',
- path: '/users/$userId',
- getParentRoute: () => rootRoute,
-})
-
-const PostsPostIdRoute = PostsPostIdImport.update({
- id: '/$postId',
- path: '/$postId',
- getParentRoute: () => PostsRoute,
-})
-
-// Create and export the route tree
-
-const PostsRouteChildren = {
- PostsPostIdRoute: PostsPostIdRoute,
-}
-
-const PostsRouteWithChildren = PostsRoute._addFileChildren(PostsRouteChildren)
-
-const rootRouteChildren = {
- IndexRoute: IndexRoute,
- PostsRoute: PostsRouteWithChildren,
- UsersUserIdRoute: UsersUserIdRoute,
-}
-
-export const routeTree = rootRoute._addFileChildren(rootRouteChildren)
-
-/* prettier-ignore-end */
-
-/* ROUTE_MANIFEST_START
-{
- "routes": {
- "__root__": {
- "filePath": "__root.tsx",
- "children": [
- "/",
- "/posts",
- "/users/$userId"
- ]
- },
- "/": {
- "filePath": "index.tsx"
- },
- "/posts": {
- "filePath": "posts.tsx",
- "children": [
- "/posts/$postId"
- ]
- },
- "/posts/$postId": {
- "filePath": "posts/$postId.tsx",
- "parent": "/posts"
- },
- "/users/$userId": {
- "filePath": "users.$userId.tsx"
- }
- }
-}
-ROUTE_MANIFEST_END */
diff --git a/packages/router-generator/tests/generator/types-disabled/routeTree.snapshot.js b/packages/router-generator/tests/generator/types-disabled/routeTree.snapshot.js
index 374efaa2fa..e7e66c3847 100644
--- a/packages/router-generator/tests/generator/types-disabled/routeTree.snapshot.js
+++ b/packages/router-generator/tests/generator/types-disabled/routeTree.snapshot.js
@@ -1,12 +1,12 @@
-/* prettier-ignore-start */
-
/* eslint-disable */
// @ts-nocheck
// noinspection JSUnusedGlobalSymbols
-// This file is auto-generated by TanStack Router
+// This file was automatically generated by TanStack Router.
+// You should NOT make any changes in this file as it will be overwritten.
+// Additionally, you should also exclude this file from your linter and/or formatter to prevent it from being checked or modified.
// Import Routes
@@ -58,8 +58,6 @@ const rootRouteChildren = {
export const routeTree = rootRoute._addFileChildren(rootRouteChildren)
-/* prettier-ignore-end */
-
/* ROUTE_MANIFEST_START
{
"routes": {
diff --git a/packages/router-generator/tests/generator/virtual-inside-nested/routeTree.snapshot.ts b/packages/router-generator/tests/generator/virtual-inside-nested/routeTree.snapshot.ts
index ae4e7e12a7..ca38556b08 100644
--- a/packages/router-generator/tests/generator/virtual-inside-nested/routeTree.snapshot.ts
+++ b/packages/router-generator/tests/generator/virtual-inside-nested/routeTree.snapshot.ts
@@ -1,12 +1,12 @@
-/* prettier-ignore-start */
-
/* eslint-disable */
// @ts-nocheck
// noinspection JSUnusedGlobalSymbols
-// This file is auto-generated by TanStack Router
+// This file was automatically generated by TanStack Router.
+// You should NOT make any changes in this file as it will be overwritten.
+// Additionally, you should also exclude this file from your linter and/or formatter to prevent it from being checked or modified.
// Import Routes
@@ -136,8 +136,6 @@ export const routeTree = rootRoute
._addFileChildren(rootRouteChildren)
._addFileTypes()
-/* prettier-ignore-end */
-
/* ROUTE_MANIFEST_START
{
"routes": {
diff --git a/packages/router-generator/tests/generator/virtual/routeTree.snapshot.ts b/packages/router-generator/tests/generator/virtual/routeTree.snapshot.ts
index 89bdba8472..0c311fd572 100644
--- a/packages/router-generator/tests/generator/virtual/routeTree.snapshot.ts
+++ b/packages/router-generator/tests/generator/virtual/routeTree.snapshot.ts
@@ -1,12 +1,12 @@
-/* prettier-ignore-start */
-
/* eslint-disable */
// @ts-nocheck
// noinspection JSUnusedGlobalSymbols
-// This file is auto-generated by TanStack Router
+// This file was automatically generated by TanStack Router.
+// You should NOT make any changes in this file as it will be overwritten.
+// Additionally, you should also exclude this file from your linter and/or formatter to prevent it from being checked or modified.
// Import Routes
@@ -296,8 +296,6 @@ export const routeTree = rootRoute
._addFileChildren(rootRouteChildren)
._addFileTypes()
-/* prettier-ignore-end */
-
/* ROUTE_MANIFEST_START
{
"routes": {
diff --git a/packages/router-plugin/package.json b/packages/router-plugin/package.json
index 803373d9b9..7efd091489 100644
--- a/packages/router-plugin/package.json
+++ b/packages/router-plugin/package.json
@@ -1,6 +1,6 @@
{
"name": "@tanstack/router-plugin",
- "version": "1.76.0",
+ "version": "1.78.2",
"description": "Modern and scalable routing for React applications",
"author": "Tanner Linsley",
"license": "MIT",
@@ -103,14 +103,14 @@
"node": ">=12"
},
"dependencies": {
- "@babel/core": "^7.25.8",
- "@babel/generator": "^7.25.7",
- "@babel/parser": "^7.25.8",
- "@babel/plugin-syntax-jsx": "^7.25.7",
- "@babel/plugin-syntax-typescript": "^7.25.7",
- "@babel/template": "^7.25.7",
- "@babel/traverse": "^7.25.7",
- "@babel/types": "^7.25.8",
+ "@babel/core": "^7.26.0",
+ "@babel/generator": "^7.26.0",
+ "@babel/parser": "^7.26.1",
+ "@babel/plugin-syntax-jsx": "^7.25.9",
+ "@babel/plugin-syntax-typescript": "^7.25.9",
+ "@babel/template": "^7.25.9",
+ "@babel/traverse": "^7.25.9",
+ "@babel/types": "^7.26.0",
"@tanstack/router-generator": "workspace:^",
"@tanstack/virtual-file-routes": "workspace:^",
"@types/babel__core": "^7.20.5",
diff --git a/packages/router-plugin/src/core/code-splitter/compilers.ts b/packages/router-plugin/src/core/code-splitter/compilers.ts
index 96ed3d8214..a320a8114e 100644
--- a/packages/router-plugin/src/core/code-splitter/compilers.ts
+++ b/packages/router-plugin/src/core/code-splitter/compilers.ts
@@ -406,6 +406,13 @@ export function compileCodeSplitVirtualRoute(opts: ParseAstOptions) {
),
]),
)
+ } else if (t.isVariableDeclarator(splitNode)) {
+ programPath.pushContainer(
+ 'body',
+ t.variableDeclaration('const', [
+ t.variableDeclarator(t.identifier(splitType), splitNode.init),
+ ]),
+ )
} else if (t.isCallExpression(splitNode)) {
const outputSplitNodeCode = generate(splitNode).code
const splitNodeAst = babel.parse(outputSplitNodeCode)
diff --git a/packages/router-plugin/tests/code-splitter/snapshots/arrow-function.tsx b/packages/router-plugin/tests/code-splitter/snapshots/arrow-function.tsx
new file mode 100644
index 0000000000..e0859d59e7
--- /dev/null
+++ b/packages/router-plugin/tests/code-splitter/snapshots/arrow-function.tsx
@@ -0,0 +1,9 @@
+const $$splitComponentImporter = () => import('tsr-split:arrow-function.tsx?tsr-split');
+import { lazyRouteComponent } from '@tanstack/react-router';
+const $$splitLoaderImporter = () => import('tsr-split:arrow-function.tsx?tsr-split');
+import { lazyFn } from '@tanstack/react-router';
+import { createFileRoute } from '@tanstack/react-router';
+export const Route = createFileRoute('/posts')({
+ loader: lazyFn($$splitLoaderImporter, 'loader'),
+ component: lazyRouteComponent($$splitComponentImporter, 'component', () => Route.ssr)
+});
\ No newline at end of file
diff --git a/packages/router-plugin/tests/code-splitter/snapshots/arrow-function@split.tsx b/packages/router-plugin/tests/code-splitter/snapshots/arrow-function@split.tsx
new file mode 100644
index 0000000000..1a07e3c317
--- /dev/null
+++ b/packages/router-plugin/tests/code-splitter/snapshots/arrow-function@split.tsx
@@ -0,0 +1,29 @@
+import { Link, Outlet } from '@tanstack/react-router';
+import { fetchPosts } from '../posts';
+import { Route } from "arrow-function.tsx";
+const component = () => {
+ const posts = Route.useLoaderData();
+ return