Question about file structure
Hello everyone!
I started using Tanstack Router recently and I'm loving it so far!
I have a question about structuring my files and folders in an admin application:
Currently the app has "organizations" and "items". An organization can create items and the platform admin can manage both items and organizations.
Right now the admin routes are
/items/$itemId.tsx
and /orgs/$orgId.tsx
, that's working as expected. My question arises from the need to do /orgs/$orgId/items/$itemId.tsx
Is there a better way to handle the use case without the need to copy the contents of items/$itemId.tsx
and duplicate them inside /orgs/$orgId/items/$itemId.tsx
?
Thanks in advance!3 Replies
conscious-sapphire•8mo ago
Only quick thing I can think of is to have the organization as a query param filter on the
items
so /items/1/?orgId=123
Otherwise, I tried to make reusable route options and components, but the router does not really like thatrare-sapphireOP•8mo ago
Ok thank you. I can always have a reusable component to be rendered by both routes but since the router has a lot of clever features related to routing params maybe there was a smarter way
conscious-sapphire•8mo ago
Some other people requested optional path params, which could potentially also be used to fix this, but not with your route structure. IMO reusable options should be the way to go.