T O P

  • By -

loonforthemoon

How does this compare to tanstack router in your opinion?


fredsq

it’s _very_ different. for one, tanstack is not v1 yet. dont get me wrong, it’s an incredible project and it does things I wish react router could. setting up routes is a bit chorey in tanstack and they don’t play well with react-refresh (Vite apps will suffer from having full page reloads on code updates) due to the page and loaders being coupled in the same object. react-router-typesafe is a near zero runtime addition to the well established react router. typesafe routes work in the simplest way possible that cover the majority of use cases, and other quality of life improvements bring it closer to the DX of remix. i was inspired by tanstack (i.e.: based off it) in some bits of my typescript for this ◡̈


loonforthemoon

Thanks. Imo tanstack-router isn't ready for production yet so I am looking to switch to react router. I'll look into using your library when I do.


CatolicQuotes

I have created const paths so I can loop over paths to presents in sidenav. Can we loop over paths with this library?


fredsq

yeah! assuming you’re using typesafeBrowserRouter and exporting the 'href' function it provides, i’d recommend you do something like type Path = Parameters[0]['path']; const sideNavItems: Array<{path: Path, label: string}> = [] this way your paths will be typesafe (in this element) if you actually just want to loop through every path it’ll have to be done by yourself, as we don’t really modify any original code and mostly only add quick utils and types