Skip to content

Best practices for directory-based routing with lots of non-route files #1493

Closed Answered by alexkatz
alexkatz asked this question in Q&A
Discussion options

You must be logged in to vote

Ultimately I decided to keep my /routes directory flat, and stick with this type of approach, which seems more of the Tanstack Router way:

accounts/
  utils.ts
  useSomeAccountsHook.ts
  constants.ts
reports/
  useSomeReportsHook.ts
  utils.ts
routes/
  __root.tsx
  accounts.tsx
  reports.tsx

And I've set up Typescript import aliases to allow statements like import useSomeAccountsHook from '@/accounts'. This flattened style of organizing by feature is nice. I'm really enjoying this setup as I port more routes over.

Replies: 3 comments 1 reply

Comment options

You must be logged in to vote
0 replies
Answer selected by alexkatz
Comment options

You must be logged in to vote
1 reply
@alexkatz
Comment options

Comment options

You must be logged in to vote
0 replies
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
3 participants