T
TanStack9mo ago
fascinating-indigo

TanStack Router vs React Router V6 -> V7 (Stable) - Which is better?

Which provides more capabilities and a better developer experience? I've ran into some warnings of React Router V7 (RR7) still using Vite 5. In addition, using the new Framework style of RR7 - namely the Router Provider Framework style, there seems to be a weird injection of clientLoader, Loader and converting the routes to use this (https://reactrouter.com/upgrading/router-provider#1-move-route-definitions-into-route-modules). Seems to be Tanstack Router is cleaner, but I'd love to know the community's opinion.
11 Replies
deep-jade
deep-jade9mo ago
https://tanstack.com/router/latest/docs/framework/react/comparison My main reason for using tanstack router is beforeLoad, as I have some routes that depend on data that is fetched in layouts and I do not want to duplicate the request code in the route's loader
fascinating-indigo
fascinating-indigoOP9mo ago
React Router 7 doesn't support any preloading?
deep-jade
deep-jade9mo ago
there's loaders, but not beforeLoad, and all loaders run in parallel so you cant wait for the data of one loader to fetch before another one launches
fascinating-indigo
fascinating-indigoOP9mo ago
now react router 7 offers a full framework vs being a library, do you foresee tanstack router losing the race of feature parity or new offerings? RR7 seems to have a bigger community
deep-jade
deep-jade9mo ago
at least from my experience, tanstack router seems to offer more features, and they are quick at fixing bugs
fascinating-indigo
fascinating-indigoOP9mo ago
appreciate your take on this
fascinating-indigo
fascinating-indigo2mo ago
React Router v7 has better code-based routing primitives. Keeps the self-built route-tree very readable and you can decide yourself where to put the files, which is very convenient!
xenial-black
xenial-black2mo ago
national-gold
national-gold2mo ago
We have just moved to TSR because we were looking for Server Sider Rendering and prerendering. Glad we did because there are a number of other features not available in React Router such as data fetching, easy error handling, easy configuration, etc etc which means we would not go back. TSR is a little more complex but it is worth the initial effort.
sensitive-blue
sensitive-blue2mo ago
RR7 has middleware which covers many of the usecase of beforeLoad
vicious-gold
vicious-gold4w ago
The dev experience is so much better in TS router. Especially in conjunction with data management. To me the only real gotcha is local style overrides to global css library themes. Global style themes are more of a legacy concept from tools like kendo versus the headless libraries that are popular today. But some of my contract requirements force me down the older path. And I've noticed that these global styles override the local ones even though they're further down the Dom tree. I'm forced to rely on inline styles or !important flags to overcome that. Not a deal breaker by any means. These are the type of clients that don't place much importance on things like design consistency or responsive design anyhow. Still, I notice 😏

Did you find this page helpful?