TanStackT
TanStack2y ago
47 replies
developed-pink

directory routes

I have a question on directory routes:
https://tanstack.com/router/latest/docs/framework/react/guide/route-trees#directory-routes

looking at the
posts
directory with
index
and $postId.tsx

should $postId be a child of the
index
route?

What I'm seeing is that they are not a child, but they are a child when I define them as a flat route with:

posts.index.tsx
posts.$postId.tsx


I think the result should be the same, right ?
Like most other routers, TanStack Router uses a nested route tree to match up the URL with the correct component tree to render.

To build a route tree, TanStack Router supports both:
Was this page helpful?