Filebased router
is there a way to create a filebased router but different folders?
7 Replies
fair-rose•2y ago
Do you mean that the URLs look like this?
Tanstack Router's file-based routing configuration relies on the structure the Route config files that are placed in the routes folder to represent the URL hierarchy.
Using this, it then builds the routeTree which is consumed by the router whilst handling the relevant code-splitting.
fair-roseOP•2y ago
actually i was planning to put routes on each features, do you advise to have one route file vs dividing it into features?
fair-rose•2y ago
I'd personally divide it.
Checkout the Basic File Based in the docs, it'll help you.
fair-roseOP•2y ago
i was thinking something like this. I'm not even sure if this elegant, but i was planning breaking down my routes
fair-rose•2y ago
Oh you meant like that!
The file-based approach is opinionated to an extent, requiring the route hierarchy to be built within a single routes folder.
Additionally, the router-cli (used for the file-based approach) only supports a single entry routes folder.
So you wouldn't be able to split it up as such.
What is the actual requirement here for splitting-up your routes based on features? because your application routing is never dependent on the features you are shipping.
fair-roseOP•2y ago
nothing really just really want them to split, right now doing code base routing, but it has been tiringsome
probably the best route now is to create my own generate for now
solid-orange•2y ago
Have you considered using file based routing as described in tanstack’s docs, but then building your components in a separate set of directories? You can organize your code however you want, and then import the components you wish to mount inside the routes directory.