Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 22 additions & 0 deletions docs/start/framework/react/guide/routing.md
Original file line number Diff line number Diff line change
Expand Up @@ -202,6 +202,28 @@ To create a route, create a new file that corresponds to the path of the route y
| `/posts/:postId` | `posts/$postId.tsx` | Dynamic Route |
| `/rest/*` | `rest/$.tsx` | Wildcard Route |

When the route generator creates a file such as `posts.tsx`, it adds a starter
component. Because `posts.tsx` is the parent of `posts/index.tsx` and
`posts/$postId.tsx`, its component must render an `<Outlet />` for those child
routes to appear:

```tsx title="src/routes/posts.tsx"
import { Outlet, createFileRoute } from '@tanstack/react-router'

export const Route = createFileRoute('/posts')({
component: PostsLayout,
})

function PostsLayout() {
return <Outlet />
}
```

Place `<Outlet />` wherever the child route should render within any shared
layout UI. If the parent route does not need a component, remove the generated
`component` option instead; a route without a component renders an outlet
automatically.

## Defining Routes

To define a route, use the `createFileRoute` function to export the route as the `Route` variable.
Expand Down
22 changes: 22 additions & 0 deletions docs/start/framework/solid/guide/routing.md
Original file line number Diff line number Diff line change
Expand Up @@ -198,6 +198,28 @@ To create a route, create a new file that corresponds to the path of the route y
| `/posts/:postId` | `posts/$postId.tsx` | Dynamic Route |
| `/rest/*` | `rest/$.tsx` | Wildcard Route |

When the route generator creates a file such as `posts.tsx`, it adds a starter
component. Because `posts.tsx` is the parent of `posts/index.tsx` and
`posts/$postId.tsx`, its component must render an `<Outlet />` for those child
routes to appear:

```tsx title="src/routes/posts.tsx"
import { Outlet, createFileRoute } from '@tanstack/solid-router'

export const Route = createFileRoute('/posts')({
component: PostsLayout,
})

function PostsLayout() {
return <Outlet />
}
```

Place `<Outlet />` wherever the child route should render within any shared
layout UI. If the parent route does not need a component, remove the generated
`component` option instead; a route without a component renders an outlet
automatically.

## Defining Routes

To define a route, use the `createFileRoute` function to export the route as the `Route` variable.
Expand Down