router icon indicating copy to clipboard operation
router copied to clipboard

[tanstack router docs] path option missing from createFileRoute functions in docs

Open laurentlahmy opened this issue 7 months ago • 3 comments

Which project does this relate to?

Router

Describe the bug

the path option is missing from all createFileRoute functions in the "routing concepts" page of the docs

https://tanstack.com/router/latest/docs/framework/react/routing/routing-concepts

https://github.com/TanStack/router/blob/main/docs/router/framework/react/routing/routing-concepts.md

Image

Your Example Website or App

https://tanstack.com/router/latest/docs/framework/react/routing/routing-concepts

Steps to Reproduce the Bug or Issue

visit https://tanstack.com/router/latest/docs/framework/react/routing/routing-concepts

Expected behavior

export const Route = createFileRoute('/posts/')({ // path option should be present
  component: PostsIndexComponent,
})

Screenshots or Videos

Image

Platform

  • OS: macOS
  • Browser: Chrome, Safari

Additional context

No response

laurentlahmy avatar Jun 11 '25 03:06 laurentlahmy

Noticed this too. pretty disappointing honestly

margaretjoanmiller avatar Jun 19 '25 10:06 margaretjoanmiller

The path is not required:

"Wait, you're making me pass the path of the route file to createFileRoute?"

Yes! But don't worry, this path is automatically written and managed by the router for you via the TanStack Router Bundler Plugin or Router CLI. So, as you create new routes, move routes around or rename routes, the path will be updated for you automatically.

The reason for this pathname has everything to do with the magical type safety of TanStack Router. Without this pathname, TypeScript would have no idea what file we're in! (We wish TypeScript had a built-in for this, but they don't yet 🤷‍♂️)

doc

Take a look at the comment by @schiller-manuel

gynekolog avatar Jun 19 '25 13:06 gynekolog

Ohh so you need to run the CLI before the typescript lsp server picks up the types?

margaretjoanmiller avatar Jun 19 '25 15:06 margaretjoanmiller