TanStackT
TanStack8mo ago
13 replies
abstract-purple

Code-based routing structure in bigger apps

Hey folks! I’m using code-based routing in a larger app (not file-based), and I’m struggling a bit with how to organize routes properly.

Because of circular dependencies, I had to split each route from its addChildren() definition (route tree). On top of that, re-exporting routes from a central @router/index.ts alias causes circular issues when one route imports another via the alias.

So now I’m left with long relative imports everywhere, and I’m wondering:

How do you structure your routes in code-based routing at scale?
- Do you use alias like @routes?
- Do you colocate route + routeTree?
- How do you avoid circulars and keep things clean?

Any patterns or real-world examples appreciated

Thank you!
Was this page helpful?