r/reactjs • • Sep 14 '25

Discussion File-based routing vs code-based routing in TanStack router, which one do you use and why?

[deleted] — view deleted post

35 Upvotes

33 comments sorted by

View all comments

13

u/Confused_Dev_Q Sep 14 '25 edited Sep 14 '25

I prefer code based routing in webapps, file based routing in websites.

File based is nice but it limits you in certain ways. You have to name files a certain way and you can't structure your project exactly how you want. 

Code based routing allows you do split authenticated/non-authenticated parts easily, while in file based you'd rely on middleware etc