<html lang="en">
<head></head>
<body>

<form id="mainForm" method="post" action="https://stackblitz.com/run" target="_self">
<input type="hidden" name="project[files][.gitignore]" value="node_modules
.DS_Store
dist
dist-ssr
*.local

/test-results/
/playwright-report/
/blob-report/
/playwright/.cache/
">
<input type="hidden" name="project[files][README.md]" value="# TanStack Router - Virtual Inside File-Based Routing Example

An example demonstrating virtual routes within a file-based routing structure.

- [TanStack Router Docs](https://tanstack.com/router)

## Start a new project based on this example

To start a new project based on this example, run:

```sh
npx gitpick TanStack/router/tree/main/examples/react/basic-virtual-inside-file-based basic-virtual-inside-file-based
```

## Getting Started

Install dependencies:

```sh
pnpm install
```

Start the development server:

```sh
pnpm dev
```

## Build

Build for production:

```sh
pnpm build
```

## About This Example

This example demonstrates:

- Combining virtual and file-based routing
- Hybrid routing approach
- Dynamic route generation within file-based structure
- Flexible route configuration
">
<input type="hidden" name="project[files][index.html]" value="&lt;!doctype html&gt;
&lt;html lang=&quot;en&quot;&gt;
  &lt;head&gt;
    &lt;meta charset=&quot;UTF-8&quot; /&gt;
    &lt;meta name=&quot;viewport&quot; content=&quot;width=device-width, initial-scale=1.0&quot; /&gt;
    &lt;title&gt;Vite App&lt;/title&gt;
  &lt;/head&gt;
  &lt;body&gt;
    &lt;div id=&quot;app&quot;&gt;&lt;/div&gt;
    &lt;script type=&quot;module&quot; src=&quot;/src/main.tsx&quot;&gt;&lt;/script&gt;
  &lt;/body&gt;
&lt;/html&gt;
">
<input type="hidden" name="project[files][package.json]" value="{&quot;name&quot;:&quot;tanstack-router-react-example-basic-virtual-inside-file-based&quot;,&quot;private&quot;:true,&quot;type&quot;:&quot;module&quot;,&quot;scripts&quot;:{&quot;dev&quot;:&quot;vite --port 3000&quot;,&quot;build&quot;:&quot;vite build &amp;&amp; tsc --noEmit&quot;,&quot;preview&quot;:&quot;vite preview&quot;,&quot;start&quot;:&quot;vite&quot;},&quot;dependencies&quot;:{&quot;@tailwindcss/vite&quot;:&quot;^4.1.18&quot;,&quot;@tanstack/react-router&quot;:&quot;https://pkg.pr.new/TanStack/router/@tanstack/react-router@a8b8021139e1f21e979e462e14ed8c15d4ce0f92&quot;,&quot;@tanstack/react-router-devtools&quot;:&quot;https://pkg.pr.new/TanStack/router/@tanstack/react-router-devtools@a8b8021139e1f21e979e462e14ed8c15d4ce0f92&quot;,&quot;@tanstack/router-plugin&quot;:&quot;https://pkg.pr.new/TanStack/router/@tanstack/router-plugin@a8b8021139e1f21e979e462e14ed8c15d4ce0f92&quot;,&quot;@tanstack/virtual-file-routes&quot;:&quot;https://pkg.pr.new/TanStack/router/@tanstack/virtual-file-routes@a8b8021139e1f21e979e462e14ed8c15d4ce0f92&quot;,&quot;react&quot;:&quot;^19.0.0&quot;,&quot;react-dom&quot;:&quot;^19.0.0&quot;,&quot;redaxios&quot;:&quot;^0.5.1&quot;,&quot;tailwindcss&quot;:&quot;^4.1.18&quot;,&quot;zod&quot;:&quot;^3.24.2&quot;},&quot;devDependencies&quot;:{&quot;@types/react&quot;:&quot;^19.0.8&quot;,&quot;@types/react-dom&quot;:&quot;^19.0.3&quot;,&quot;@vitejs/plugin-react&quot;:&quot;^4.3.4&quot;,&quot;typescript&quot;:&quot;^5.7.2&quot;,&quot;vite&quot;:&quot;^7.1.7&quot;}}">
<input type="hidden" name="project[files][tsconfig.json]" value="{
  &quot;compilerOptions&quot;: {
    &quot;strict&quot;: true,
    &quot;esModuleInterop&quot;: true,
    &quot;jsx&quot;: &quot;react-jsx&quot;,
    &quot;target&quot;: &quot;ESNext&quot;,
    &quot;module&quot;: &quot;Preserve&quot;,
    &quot;moduleResolution&quot;: &quot;Bundler&quot;,
    &quot;lib&quot;: [&quot;DOM&quot;, &quot;DOM.Iterable&quot;, &quot;ES2022&quot;],
    &quot;skipLibCheck&quot;: true
  }
}
">
<input type="hidden" name="project[files][vite.config.ts]" value="import { defineConfig } from &#39;vite&#39;
import react from &#39;@vitejs/plugin-react&#39;
import { tanstackRouter } from &#39;@tanstack/router-plugin/vite&#39;
import tailwindcss from &#39;@tailwindcss/vite&#39;

// https://vitejs.dev/config/
export default defineConfig({
  plugins: [
    tailwindcss(),
    tanstackRouter({
      target: &#39;react&#39;,
      autoCodeSplitting: true,
      verboseFileRoutes: false,
    }),
    react(),
  ],
})
">
<input type="hidden" name="project[files][.vscode/settings.json]" value="{
  &quot;files.watcherExclude&quot;: {
    &quot;**/routeTree.gen.ts&quot;: true
  },
  &quot;search.exclude&quot;: {
    &quot;**/routeTree.gen.ts&quot;: true
  },
  &quot;files.readonlyInclude&quot;: {
    &quot;**/routeTree.gen.ts&quot;: true
  }
}
">
<input type="hidden" name="project[files][src/main.tsx]" value="import React from &#39;react&#39;
import ReactDOM from &#39;react-dom/client&#39;
import { RouterProvider, createRouter } from &#39;@tanstack/react-router&#39;
import { routeTree } from &#39;./routeTree.gen&#39;
import &#39;./styles.css&#39;

// Set up a Router instance
const router = createRouter({
  routeTree,
  defaultPreload: &#39;intent&#39;,
  defaultStaleTime: 5000,
  scrollRestoration: true,
})

// Register things for typesafety
declare module &#39;@tanstack/react-router&#39; {
  interface Register {
    router: typeof router
  }
}

const rootElement = document.getElementById(&#39;app&#39;)!

if (!rootElement.innerHTML) {
  const root = ReactDOM.createRoot(rootElement)
  root.render(&lt;RouterProvider router={router} /&gt;)
}
">
<input type="hidden" name="project[files][src/posts.tsx]" value="import { notFound } from &#39;@tanstack/react-router&#39;
import axios from &#39;redaxios&#39;

export type PostType = {
  id: string
  title: string
  body: string
}

export const fetchPost = async (postId: string) =&gt; {
  console.info(`Fetching post with id ${postId}...`)
  await new Promise((r) =&gt; setTimeout(r, 500))
  const post = await axios
    .get&lt;PostType&gt;(`https://jsonplaceholder.typicode.com/posts/${postId}`)
    .then((r) =&gt; r.data)
    .catch((err) =&gt; {
      if (err.status === 404) {
        throw notFound()
      }
      throw err
    })

  return post
}

export const fetchPosts = async () =&gt; {
  console.info(&#39;Fetching posts...&#39;)
  await new Promise((r) =&gt; setTimeout(r, 500))
  return axios
    .get&lt;Array&lt;PostType&gt;&gt;(&#39;https://jsonplaceholder.typicode.com/posts&#39;)
    .then((r) =&gt; r.data.slice(0, 10))
}
">
<input type="hidden" name="project[files][src/routeTree.gen.ts]" value="/* eslint-disable */

// @ts-nocheck

// noinspection JSUnusedGlobalSymbols

// 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 type { CreateFileRoute, FileRoutesByPath } from &#39;@tanstack/react-router&#39;

import { Route as rootRouteImport } from &#39;./routes/__root&#39;
import { Route as PostsRouteImport } from &#39;./routes/posts&#39;
import { Route as LayoutRouteImport } from &#39;./routes/_layout&#39;
import { Route as IndexRouteImport } from &#39;./routes/index&#39;
import { Route as postsDetailsRouteImport } from &#39;./routes/posts/details&#39;
import { Route as LayoutLayout2RouteImport } from &#39;./routes/_layout/_layout-2&#39;
import { Route as postsHomeRouteImport } from &#39;./routes/posts/home&#39;
import { Route as postsLetsGoIndexRouteImport } from &#39;./routes/posts/lets-go/index&#39;
import { Route as LayoutLayout2LayoutBRouteImport } from &#39;./routes/_layout/_layout-2/layout-b&#39;
import { Route as LayoutLayout2LayoutARouteImport } from &#39;./routes/_layout/_layout-2/layout-a&#39;
import { Route as postsLetsGoDeeperHomeRouteImport } from &#39;./routes/posts/lets-go/deeper/home&#39;

const PostsRoute = PostsRouteImport.update({
  id: &#39;/posts&#39;,
  path: &#39;/posts&#39;,
  getParentRoute: () =&gt; rootRouteImport,
} as any)
const LayoutRoute = LayoutRouteImport.update({
  id: &#39;/_layout&#39;,
  getParentRoute: () =&gt; rootRouteImport,
} as any)
const IndexRoute = IndexRouteImport.update({
  id: &#39;/&#39;,
  path: &#39;/&#39;,
  getParentRoute: () =&gt; rootRouteImport,
} as any)
const postsDetailsRoute = postsDetailsRouteImport.update({
  id: &#39;/$postId&#39;,
  path: &#39;/$postId&#39;,
  getParentRoute: () =&gt; PostsRoute,
} as any)
const LayoutLayout2Route = LayoutLayout2RouteImport.update({
  id: &#39;/_layout-2&#39;,
  getParentRoute: () =&gt; LayoutRoute,
} as any)
const postsHomeRoute = postsHomeRouteImport.update({
  id: &#39;/&#39;,
  path: &#39;/&#39;,
  getParentRoute: () =&gt; PostsRoute,
} as any)
const postsLetsGoIndexRoute = postsLetsGoIndexRouteImport.update({
  id: &#39;/inception/&#39;,
  path: &#39;/inception/&#39;,
  getParentRoute: () =&gt; PostsRoute,
} as any)
const LayoutLayout2LayoutBRoute = LayoutLayout2LayoutBRouteImport.update({
  id: &#39;/layout-b&#39;,
  path: &#39;/layout-b&#39;,
  getParentRoute: () =&gt; LayoutLayout2Route,
} as any)
const LayoutLayout2LayoutARoute = LayoutLayout2LayoutARouteImport.update({
  id: &#39;/layout-a&#39;,
  path: &#39;/layout-a&#39;,
  getParentRoute: () =&gt; LayoutLayout2Route,
} as any)
const postsLetsGoDeeperHomeRoute = postsLetsGoDeeperHomeRouteImport.update({
  id: &#39;/inception/deeper/&#39;,
  path: &#39;/inception/deeper/&#39;,
  getParentRoute: () =&gt; PostsRoute,
} as any)

export interface FileRoutesByFullPath {
  &#39;/&#39;: typeof IndexRoute
  &#39;/posts&#39;: typeof PostsRouteWithChildren
  &#39;/posts/&#39;: typeof postsHomeRoute
  &#39;/posts/$postId&#39;: typeof postsDetailsRoute
  &#39;/layout-a&#39;: typeof LayoutLayout2LayoutARoute
  &#39;/layout-b&#39;: typeof LayoutLayout2LayoutBRoute
  &#39;/posts/inception&#39;: typeof postsLetsGoIndexRoute
  &#39;/posts/inception/deeper&#39;: typeof postsLetsGoDeeperHomeRoute
}
export interface FileRoutesByTo {
  &#39;/&#39;: typeof IndexRoute
  &#39;/posts&#39;: typeof postsHomeRoute
  &#39;/posts/$postId&#39;: typeof postsDetailsRoute
  &#39;/layout-a&#39;: typeof LayoutLayout2LayoutARoute
  &#39;/layout-b&#39;: typeof LayoutLayout2LayoutBRoute
  &#39;/posts/inception&#39;: typeof postsLetsGoIndexRoute
  &#39;/posts/inception/deeper&#39;: typeof postsLetsGoDeeperHomeRoute
}
export interface FileRoutesById {
  __root__: typeof rootRouteImport
  &#39;/&#39;: typeof IndexRoute
  &#39;/_layout&#39;: typeof LayoutRouteWithChildren
  &#39;/posts&#39;: typeof PostsRouteWithChildren
  &#39;/posts/&#39;: typeof postsHomeRoute
  &#39;/_layout/_layout-2&#39;: typeof LayoutLayout2RouteWithChildren
  &#39;/posts/$postId&#39;: typeof postsDetailsRoute
  &#39;/_layout/_layout-2/layout-a&#39;: typeof LayoutLayout2LayoutARoute
  &#39;/_layout/_layout-2/layout-b&#39;: typeof LayoutLayout2LayoutBRoute
  &#39;/posts/inception/&#39;: typeof postsLetsGoIndexRoute
  &#39;/posts/inception/deeper/&#39;: typeof postsLetsGoDeeperHomeRoute
}
export interface FileRouteTypes {
  fileRoutesByFullPath: FileRoutesByFullPath
  fullPaths:
    | &#39;/&#39;
    | &#39;/posts&#39;
    | &#39;/posts/&#39;
    | &#39;/posts/$postId&#39;
    | &#39;/layout-a&#39;
    | &#39;/layout-b&#39;
    | &#39;/posts/inception&#39;
    | &#39;/posts/inception/deeper&#39;
  fileRoutesByTo: FileRoutesByTo
  to:
    | &#39;/&#39;
    | &#39;/posts&#39;
    | &#39;/posts/$postId&#39;
    | &#39;/layout-a&#39;
    | &#39;/layout-b&#39;
    | &#39;/posts/inception&#39;
    | &#39;/posts/inception/deeper&#39;
  id:
    | &#39;__root__&#39;
    | &#39;/&#39;
    | &#39;/_layout&#39;
    | &#39;/posts&#39;
    | &#39;/posts/&#39;
    | &#39;/_layout/_layout-2&#39;
    | &#39;/posts/$postId&#39;
    | &#39;/_layout/_layout-2/layout-a&#39;
    | &#39;/_layout/_layout-2/layout-b&#39;
    | &#39;/posts/inception/&#39;
    | &#39;/posts/inception/deeper/&#39;
  fileRoutesById: FileRoutesById
}
export interface RootRouteChildren {
  IndexRoute: typeof IndexRoute
  LayoutRoute: typeof LayoutRouteWithChildren
  PostsRoute: typeof PostsRouteWithChildren
}

declare module &#39;@tanstack/react-router&#39; {
  interface FileRoutesByPath {
    &#39;/posts&#39;: {
      id: &#39;/posts&#39;
      path: &#39;/posts&#39;
      fullPath: &#39;/posts&#39;
      preLoaderRoute: typeof PostsRouteImport
      parentRoute: typeof rootRouteImport
    }
    &#39;/_layout&#39;: {
      id: &#39;/_layout&#39;
      path: &#39;&#39;
      fullPath: &#39;&#39;
      preLoaderRoute: typeof LayoutRouteImport
      parentRoute: typeof rootRouteImport
    }
    &#39;/&#39;: {
      id: &#39;/&#39;
      path: &#39;/&#39;
      fullPath: &#39;/&#39;
      preLoaderRoute: typeof IndexRouteImport
      parentRoute: typeof rootRouteImport
    }
    &#39;/posts/$postId&#39;: {
      id: &#39;/posts/$postId&#39;
      path: &#39;/$postId&#39;
      fullPath: &#39;/posts/$postId&#39;
      preLoaderRoute: typeof postsDetailsRouteImport
      parentRoute: typeof PostsRoute
    }
    &#39;/_layout/_layout-2&#39;: {
      id: &#39;/_layout/_layout-2&#39;
      path: &#39;&#39;
      fullPath: &#39;&#39;
      preLoaderRoute: typeof LayoutLayout2RouteImport
      parentRoute: typeof LayoutRoute
    }
    &#39;/posts/&#39;: {
      id: &#39;/posts/&#39;
      path: &#39;/&#39;
      fullPath: &#39;/posts/&#39;
      preLoaderRoute: typeof postsHomeRouteImport
      parentRoute: typeof PostsRoute
    }
    &#39;/posts/inception/&#39;: {
      id: &#39;/posts/inception/&#39;
      path: &#39;/inception&#39;
      fullPath: &#39;/posts/inception&#39;
      preLoaderRoute: typeof postsLetsGoIndexRouteImport
      parentRoute: typeof PostsRoute
    }
    &#39;/_layout/_layout-2/layout-b&#39;: {
      id: &#39;/_layout/_layout-2/layout-b&#39;
      path: &#39;/layout-b&#39;
      fullPath: &#39;/layout-b&#39;
      preLoaderRoute: typeof LayoutLayout2LayoutBRouteImport
      parentRoute: typeof LayoutLayout2Route
    }
    &#39;/_layout/_layout-2/layout-a&#39;: {
      id: &#39;/_layout/_layout-2/layout-a&#39;
      path: &#39;/layout-a&#39;
      fullPath: &#39;/layout-a&#39;
      preLoaderRoute: typeof LayoutLayout2LayoutARouteImport
      parentRoute: typeof LayoutLayout2Route
    }
    &#39;/posts/inception/deeper/&#39;: {
      id: &#39;/posts/inception/deeper/&#39;
      path: &#39;/inception/deeper&#39;
      fullPath: &#39;/posts/inception/deeper&#39;
      preLoaderRoute: typeof postsLetsGoDeeperHomeRouteImport
      parentRoute: typeof PostsRoute
    }
  }
}

declare module &#39;./routes/index&#39; {
  const createFileRoute: CreateFileRoute&lt;
    &#39;/&#39;,
    FileRoutesByPath[&#39;/&#39;][&#39;parentRoute&#39;],
    FileRoutesByPath[&#39;/&#39;][&#39;id&#39;],
    FileRoutesByPath[&#39;/&#39;][&#39;path&#39;],
    FileRoutesByPath[&#39;/&#39;][&#39;fullPath&#39;]
  &gt;
}
declare module &#39;./routes/_layout&#39; {
  const createFileRoute: CreateFileRoute&lt;
    &#39;/_layout&#39;,
    FileRoutesByPath[&#39;/_layout&#39;][&#39;parentRoute&#39;],
    FileRoutesByPath[&#39;/_layout&#39;][&#39;id&#39;],
    FileRoutesByPath[&#39;/_layout&#39;][&#39;path&#39;],
    FileRoutesByPath[&#39;/_layout&#39;][&#39;fullPath&#39;]
  &gt;
}
declare module &#39;./routes/posts&#39; {
  const createFileRoute: CreateFileRoute&lt;
    &#39;/posts&#39;,
    FileRoutesByPath[&#39;/posts&#39;][&#39;parentRoute&#39;],
    FileRoutesByPath[&#39;/posts&#39;][&#39;id&#39;],
    FileRoutesByPath[&#39;/posts&#39;][&#39;path&#39;],
    FileRoutesByPath[&#39;/posts&#39;][&#39;fullPath&#39;]
  &gt;
}
declare module &#39;./routes/posts/home&#39; {
  const createFileRoute: CreateFileRoute&lt;
    &#39;/posts/&#39;,
    FileRoutesByPath[&#39;/posts/&#39;][&#39;parentRoute&#39;],
    FileRoutesByPath[&#39;/posts/&#39;][&#39;id&#39;],
    FileRoutesByPath[&#39;/posts/&#39;][&#39;path&#39;],
    FileRoutesByPath[&#39;/posts/&#39;][&#39;fullPath&#39;]
  &gt;
}
declare module &#39;./routes/_layout/_layout-2&#39; {
  const createFileRoute: CreateFileRoute&lt;
    &#39;/_layout/_layout-2&#39;,
    FileRoutesByPath[&#39;/_layout/_layout-2&#39;][&#39;parentRoute&#39;],
    FileRoutesByPath[&#39;/_layout/_layout-2&#39;][&#39;id&#39;],
    FileRoutesByPath[&#39;/_layout/_layout-2&#39;][&#39;path&#39;],
    FileRoutesByPath[&#39;/_layout/_layout-2&#39;][&#39;fullPath&#39;]
  &gt;
}
declare module &#39;./routes/posts/details&#39; {
  const createFileRoute: CreateFileRoute&lt;
    &#39;/posts/$postId&#39;,
    FileRoutesByPath[&#39;/posts/$postId&#39;][&#39;parentRoute&#39;],
    FileRoutesByPath[&#39;/posts/$postId&#39;][&#39;id&#39;],
    FileRoutesByPath[&#39;/posts/$postId&#39;][&#39;path&#39;],
    FileRoutesByPath[&#39;/posts/$postId&#39;][&#39;fullPath&#39;]
  &gt;
}
declare module &#39;./routes/_layout/_layout-2/layout-a&#39; {
  const createFileRoute: CreateFileRoute&lt;
    &#39;/_layout/_layout-2/layout-a&#39;,
    FileRoutesByPath[&#39;/_layout/_layout-2/layout-a&#39;][&#39;parentRoute&#39;],
    FileRoutesByPath[&#39;/_layout/_layout-2/layout-a&#39;][&#39;id&#39;],
    FileRoutesByPath[&#39;/_layout/_layout-2/layout-a&#39;][&#39;path&#39;],
    FileRoutesByPath[&#39;/_layout/_layout-2/layout-a&#39;][&#39;fullPath&#39;]
  &gt;
}
declare module &#39;./routes/_layout/_layout-2/layout-b&#39; {
  const createFileRoute: CreateFileRoute&lt;
    &#39;/_layout/_layout-2/layout-b&#39;,
    FileRoutesByPath[&#39;/_layout/_layout-2/layout-b&#39;][&#39;parentRoute&#39;],
    FileRoutesByPath[&#39;/_layout/_layout-2/layout-b&#39;][&#39;id&#39;],
    FileRoutesByPath[&#39;/_layout/_layout-2/layout-b&#39;][&#39;path&#39;],
    FileRoutesByPath[&#39;/_layout/_layout-2/layout-b&#39;][&#39;fullPath&#39;]
  &gt;
}
declare module &#39;./routes/posts/lets-go/index&#39; {
  const createFileRoute: CreateFileRoute&lt;
    &#39;/posts/inception/&#39;,
    FileRoutesByPath[&#39;/posts/inception/&#39;][&#39;parentRoute&#39;],
    FileRoutesByPath[&#39;/posts/inception/&#39;][&#39;id&#39;],
    FileRoutesByPath[&#39;/posts/inception/&#39;][&#39;path&#39;],
    FileRoutesByPath[&#39;/posts/inception/&#39;][&#39;fullPath&#39;]
  &gt;
}
declare module &#39;./routes/posts/lets-go/deeper/home&#39; {
  const createFileRoute: CreateFileRoute&lt;
    &#39;/posts/inception/deeper/&#39;,
    FileRoutesByPath[&#39;/posts/inception/deeper/&#39;][&#39;parentRoute&#39;],
    FileRoutesByPath[&#39;/posts/inception/deeper/&#39;][&#39;id&#39;],
    FileRoutesByPath[&#39;/posts/inception/deeper/&#39;][&#39;path&#39;],
    FileRoutesByPath[&#39;/posts/inception/deeper/&#39;][&#39;fullPath&#39;]
  &gt;
}

interface LayoutLayout2RouteChildren {
  LayoutLayout2LayoutARoute: typeof LayoutLayout2LayoutARoute
  LayoutLayout2LayoutBRoute: typeof LayoutLayout2LayoutBRoute
}

const LayoutLayout2RouteChildren: LayoutLayout2RouteChildren = {
  LayoutLayout2LayoutARoute: LayoutLayout2LayoutARoute,
  LayoutLayout2LayoutBRoute: LayoutLayout2LayoutBRoute,
}

const LayoutLayout2RouteWithChildren = LayoutLayout2Route._addFileChildren(
  LayoutLayout2RouteChildren,
)

interface LayoutRouteChildren {
  LayoutLayout2Route: typeof LayoutLayout2RouteWithChildren
}

const LayoutRouteChildren: LayoutRouteChildren = {
  LayoutLayout2Route: LayoutLayout2RouteWithChildren,
}

const LayoutRouteWithChildren =
  LayoutRoute._addFileChildren(LayoutRouteChildren)

interface PostsRouteChildren {
  postsHomeRoute: typeof postsHomeRoute
  postsDetailsRoute: typeof postsDetailsRoute
  postsLetsGoIndexRoute: typeof postsLetsGoIndexRoute
  postsLetsGoDeeperHomeRoute: typeof postsLetsGoDeeperHomeRoute
}

const PostsRouteChildren: PostsRouteChildren = {
  postsHomeRoute: postsHomeRoute,
  postsDetailsRoute: postsDetailsRoute,
  postsLetsGoIndexRoute: postsLetsGoIndexRoute,
  postsLetsGoDeeperHomeRoute: postsLetsGoDeeperHomeRoute,
}

const PostsRouteWithChildren = PostsRoute._addFileChildren(PostsRouteChildren)

const rootRouteChildren: RootRouteChildren = {
  IndexRoute: IndexRoute,
  LayoutRoute: LayoutRouteWithChildren,
  PostsRoute: PostsRouteWithChildren,
}
export const routeTree = rootRouteImport
  ._addFileChildren(rootRouteChildren)
  ._addFileTypes&lt;FileRouteTypes&gt;()
">
<input type="hidden" name="project[files][src/styles.css]" value="@import &#39;tailwindcss&#39;;

@layer base {
  *,
  ::after,
  ::before,
  ::backdrop,
  ::file-selector-button {
    border-color: var(--color-gray-200, currentcolor);
  }
}

html {
  color-scheme: light dark;
}
* {
  @apply border-gray-200 dark:border-gray-800;
}
body {
  @apply bg-gray-50 text-gray-950 dark:bg-gray-900 dark:text-gray-200;
}
">
<input type="hidden" name="project[files][src/routes/__root.tsx]" value="import * as React from &#39;react&#39;
import { Link, Outlet, createRootRoute } from &#39;@tanstack/react-router&#39;
import { TanStackRouterDevtools } from &#39;@tanstack/react-router-devtools&#39;

export const Route = createRootRoute({
  component: RootComponent,
  notFoundComponent: () =&gt; {
    return (
      &lt;div&gt;
        &lt;p&gt;This is the notFoundComponent configured on root route&lt;/p&gt;
        &lt;Link to=&quot;/&quot;&gt;Start Over&lt;/Link&gt;
      &lt;/div&gt;
    )
  },
})

function RootComponent() {
  return (
    &lt;&gt;
      &lt;div className=&quot;p-2 flex gap-2 text-lg border-b&quot;&gt;
        &lt;Link
          to=&quot;/&quot;
          activeProps={{
            className: &#39;font-bold&#39;,
          }}
          activeOptions={{ exact: true }}
        &gt;
          Home
        &lt;/Link&gt;{&#39; &#39;}
        &lt;Link
          to=&quot;/posts&quot;
          activeProps={{
            className: &#39;font-bold&#39;,
          }}
        &gt;
          Posts
        &lt;/Link&gt;{&#39; &#39;}
        &lt;Link
          to=&quot;/layout-a&quot;
          activeProps={{
            className: &#39;font-bold&#39;,
          }}
        &gt;
          Layout
        &lt;/Link&gt;{&#39; &#39;}
        &lt;Link
          // @ts-expect-error
          to=&quot;/this-route-does-not-exist&quot;
          activeProps={{
            className: &#39;font-bold&#39;,
          }}
        &gt;
          This Route Does Not Exist
        &lt;/Link&gt;
      &lt;/div&gt;
      &lt;hr /&gt;
      &lt;Outlet /&gt;
      {/* Start rendering router matches */}
      &lt;TanStackRouterDevtools position=&quot;bottom-right&quot; /&gt;
    &lt;/&gt;
  )
}
">
<input type="hidden" name="project[files][src/routes/_layout.tsx]" value="import { Outlet } from &#39;@tanstack/react-router&#39;

export const Route = createFileRoute({
  component: LayoutComponent,
})

function LayoutComponent() {
  return (
    &lt;div className=&quot;p-2&quot;&gt;
      &lt;div className=&quot;border-b&quot;&gt;I&#39;m a layout&lt;/div&gt;
      &lt;div&gt;
        &lt;Outlet /&gt;
      &lt;/div&gt;
    &lt;/div&gt;
  )
}
">
<input type="hidden" name="project[files][src/routes/index.tsx]" value="import * as React from &#39;react&#39;

export const Route = createFileRoute({
  component: Home,
})

function Home() {
  return (
    &lt;div className=&quot;p-2&quot;&gt;
      &lt;h3&gt;Welcome Home!&lt;/h3&gt;
    &lt;/div&gt;
  )
}
">
<input type="hidden" name="project[files][src/routes/posts.tsx]" value="import * as React from &#39;react&#39;
import { Link, Outlet } from &#39;@tanstack/react-router&#39;
import { fetchPosts } from &#39;../posts&#39;

export const Route = createFileRoute({
  loader: fetchPosts,
  component: PostsComponent,
})

function PostsComponent() {
  const posts = Route.useLoaderData()

  return (
    &lt;div className=&quot;p-2 flex gap-2&quot;&gt;
      &lt;ul className=&quot;list-disc pl-4&quot;&gt;
        {[...posts, { id: &#39;i-do-not-exist&#39;, title: &#39;Non-existent Post&#39; }].map(
          (post) =&gt; {
            return (
              &lt;li key={post.id} className=&quot;whitespace-nowrap&quot;&gt;
                &lt;Link
                  to=&quot;/posts/$postId&quot;
                  params={{
                    postId: post.id,
                  }}
                  className=&quot;block py-1 text-blue-600 hover:opacity-75&quot;
                  activeProps={{ className: &#39;font-bold underline&#39; }}
                &gt;
                  &lt;div&gt;{post.title.substring(0, 20)}&lt;/div&gt;
                &lt;/Link&gt;
              &lt;/li&gt;
            )
          },
        )}
      &lt;/ul&gt;
      &lt;hr /&gt;
      &lt;Outlet /&gt;
    &lt;/div&gt;
  )
}
">
<input type="hidden" name="project[files][src/routes/_layout/_layout-2.tsx]" value="import { Link, Outlet } from &#39;@tanstack/react-router&#39;

export const Route = createFileRoute({
  component: LayoutComponent,
})

function LayoutComponent() {
  return (
    &lt;div&gt;
      &lt;div&gt;I&#39;m a nested layout&lt;/div&gt;
      &lt;div className=&quot;flex gap-2 border-b&quot;&gt;
        &lt;Link
          to=&quot;/layout-a&quot;
          activeProps={{
            className: &#39;font-bold&#39;,
          }}
        &gt;
          Layout A
        &lt;/Link&gt;
        &lt;Link
          to=&quot;/layout-b&quot;
          activeProps={{
            className: &#39;font-bold&#39;,
          }}
        &gt;
          Layout B
        &lt;/Link&gt;
      &lt;/div&gt;
      &lt;div&gt;
        &lt;Outlet /&gt;
      &lt;/div&gt;
    &lt;/div&gt;
  )
}
">
<input type="hidden" name="project[files][src/routes/posts/__virtual.ts]" value="import {
  defineVirtualSubtreeConfig,
  index,
  physical,
  route,
} from &#39;@tanstack/virtual-file-routes&#39;

// this just shows that you can use an async function to define your virtual routes
export default defineVirtualSubtreeConfig(async () =&gt; [
  index(&#39;home.tsx&#39;),
  route(&#39;$postId&#39;, &#39;details.tsx&#39;),
  physical(&#39;/inception&#39;, &#39;lets-go&#39;),
])
">
<input type="hidden" name="project[files][src/routes/posts/details.tsx]" value="import * as React from &#39;react&#39;
import { ErrorComponent } from &#39;@tanstack/react-router&#39;
import { fetchPost } from &#39;../../posts&#39;
import type { ErrorComponentProps } from &#39;@tanstack/react-router&#39;

export const Route = createFileRoute({
  loader: async ({ params: { postId } }) =&gt; fetchPost(postId),
  errorComponent: PostErrorComponent,
  notFoundComponent: () =&gt; {
    return &lt;p&gt;Post not found&lt;/p&gt;
  },
  component: PostComponent,
})

export function PostErrorComponent({ error }: ErrorComponentProps) {
  return &lt;ErrorComponent error={error} /&gt;
}

function PostComponent() {
  const post = Route.useLoaderData()

  return (
    &lt;div className=&quot;space-y-2&quot;&gt;
      &lt;h4 className=&quot;text-xl font-bold underline&quot;&gt;{post.title}&lt;/h4&gt;
      &lt;div className=&quot;text-sm&quot;&gt;{post.body}&lt;/div&gt;
    &lt;/div&gt;
  )
}
">
<input type="hidden" name="project[files][src/routes/posts/home.tsx]" value="import * as React from &#39;react&#39;

export const Route = createFileRoute({
  component: PostsIndexComponent,
})

function PostsIndexComponent() {
  return &lt;div&gt;Select a post.&lt;/div&gt;
}
">
<input type="hidden" name="project[files][src/routes/_layout/_layout-2/layout-a.tsx]" value="export const Route = createFileRoute({
  component: LayoutAComponent,
})

function LayoutAComponent() {
  return &lt;div&gt;I&#39;m layout A!&lt;/div&gt;
}
">
<input type="hidden" name="project[files][src/routes/_layout/_layout-2/layout-b.tsx]" value="export const Route = createFileRoute({
  component: LayoutBComponent,
})

function LayoutBComponent() {
  return &lt;div&gt;I&#39;m layout B!&lt;/div&gt;
}
">
<input type="hidden" name="project[files][src/routes/posts/lets-go/index.tsx]" value="export const Route = createFileRoute({
  component: () =&gt; &lt;div&gt;Hello /posts/inception/!&lt;/div&gt;,
})
">
<input type="hidden" name="project[files][src/routes/posts/lets-go/deeper/__virtual.ts]" value="import {
  defineVirtualSubtreeConfig,
  index,
} from &#39;@tanstack/virtual-file-routes&#39;

export default defineVirtualSubtreeConfig([index(&#39;home.tsx&#39;)])
">
<input type="hidden" name="project[files][src/routes/posts/lets-go/deeper/home.tsx]" value="export const Route = createFileRoute({
  component: () =&gt; &lt;div&gt;Hello /posts/inception/deeper/!&lt;/div&gt;,
})
">
<input type="hidden" name="project[description]" value="generated by https://pkg.pr.new">
<input type="hidden" name="project[template]" value="node">
<input type="hidden" name="project[title]" value="tanstack-router-react-example-basic-virtual-inside-file-based">
</form>
<script>document.getElementById("mainForm").submit();</script>

</body></html>