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

Show parent comment

23

u/Abs0rbed Sep 14 '25

Once you get into heavier routing you need to jump into a bunch of the specially named files so your directories look like a mess. It kind of gets annoying figuring out which of the dozen __route.tsx files I have open is the right one in my editor. But it’s convenient for now so I have no need to change

2

u/wbdvlpr Sep 14 '25

Why don’t you move the file one level up and rename it? So instead of routes/users/route.tsx you would have routes/users.tsx (or routes/users.route.tsx) and keep all the child routes in routes/users/

1

u/kredditorr Sep 14 '25

The schroedingers file thingy is my personal hell. Idk about your ide, but jetbrains tools have a setting to show the opened/active file in the folder tree navigation. So I‘m sure this exists for other ides as well. Might help you with this issue.

1

u/t33lu Sep 15 '25

i don't even bother figuring out which file i have opened anymore. I just search for the same file over and over again. I've caught myself searching for a file that is opened in another window.