You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Looking at different routers and wanted to give tanstack a try, but I'm very confused from the docs and examples about how routes seems to duplicate the actual path.
If I use file based routing, then the path inherently exists based on the path to the route file, or if I use virtual file routes, then it's defined by the route config.
But at the same time, it seems like both these are only allowed to point at a 'route' file, which inside of it contains a call like createFileRoute("/path/sub/route-a"), which... contains that same exact path? What's the point of having it in both places?
Weirder, I found createRoute, which I assumed would be more generic and allow me to not specify the file path, but it actually seems to require a path, while the path in createFileRoute is optional? Seems backwards...
Is using createFileRoute without providing a path, especially with virtual routes, going to break something, or are the docs just a bit misleading?
Alternately, is there a way to only use the paths passed to createFileRoute, freeing me to organize my files how I want and not have to manually build a virtual route hierarchy somewhere? (preferably one that will also work with tanstack start SSR...)
reacted with thumbs up emoji reacted with thumbs down emoji reacted with laugh emoji reacted with hooray emoji reacted with confused emoji reacted with heart emoji reacted with rocket emoji reacted with eyes emoji
Uh oh!
There was an error while loading. Please reload this page.
-
Looking at different routers and wanted to give tanstack a try, but I'm very confused from the docs and examples about how routes seems to duplicate the actual path.
If I use file based routing, then the path inherently exists based on the path to the route file, or if I use virtual file routes, then it's defined by the route config.
But at the same time, it seems like both these are only allowed to point at a 'route' file, which inside of it contains a call like
createFileRoute("/path/sub/route-a"), which... contains that same exact path? What's the point of having it in both places?Weirder, I found
createRoute, which I assumed would be more generic and allow me to not specify the file path, but it actually seems to require a path, while the path increateFileRouteis optional? Seems backwards...the
createFileRoutedocs say that the path is required despite being optional, but that it'll be automatically generated, but I was able to create a test case where I don't pass any path and it works fine ?Is using createFileRoute without providing a path, especially with virtual routes, going to break something, or are the docs just a bit misleading?
Alternately, is there a way to only use the paths passed to
createFileRoute, freeing me to organize my files how I want and not have to manually build a virtual route hierarchy somewhere? (preferably one that will also work with tanstack start SSR...)Beta Was this translation helpful? Give feedback.
All reactions