Tanstack Router #6846
Replies: 1 comment 1 reply
-
Hello @JuicyBenjamin thanks for bringing up this discussion. IIRC, we had an issue earlier about Tanstack Router but at the time it wasn't stable yet, so we wanted to wait for it to be stable before integrating it into Refine. As you mentioned, Refine's headless architecture focuses on client-side only, and that part of the integration can be done relatively easier. You can see the relevant docs here: https://refine.dev/docs/routing/router-provider/ If we oversimplify things, you'd need to implement 4 methods that binds to Tanstack Router to make it work at minimum level. Typesafe query params and all other things would needs to be thought. But also, Refine already handles query params internally, so unless you have a specific use-case, you shouldn't need to deal with them too much. |
Beta Was this translation helpful? Give feedback.
Uh oh!
There was an error while loading. Please reload this page.
-
I am only minimally familiar with tanstack router and have not used it myself in any project, yet. However I am very aware of all the benefits having a type safe router. In fact in a way Refine attempted to solve this by having a predetermined for how to structure routes, with :id params for example that should always represent the current resource item. While this pattern is extremely useful, and arguably one of the things that make useful, it is at times a bit naive.
I've previously opened a request for having nested routes and resources and in this scenario this naive pattern falls apart, as you can't as you will overwrite all params with the same name, in this case :id .
However not solely relying on :id as param puts on into very unsafe, type wise, territory. And we now have to eject from refine as a result. Now for refine to support this sort of pattern, type safety is required.
Introducing Tanstack router, the type safe option.
Only problem is, in spite of a lot of core functionality in refine is built on top of tanstack libraries, I think the router is fundamentally at odds with the refine approach. Which I'm guessing is why there are no official integration yet, and the refine team has opted to ask for a community implementation. While I'm very much for that, I think a lot of hooks needs to be rewritten for this to work properly.
Problems:
Here are a few of the problems that I think stand in the way of this fantastic integration
Benefits:
Now this of course isn't an exhaustive list of neither the problems nor the benefits associated with a tanstack router integration, but these were the ones off the top of my head.
I am very open to contribute, but am not familiar enough with neither tanstack router nor refine internals, but I think that's just a matter of time. I intend on rewriting a small side project I have in react router to get more familiar with tanstack router and then I'm thinking of making a dummy project with refine to see if I can somehow built a shell on top of refine to make it somewhat integrate seemlessly. But I think the ladder would be very helpful if I got some pointers, I've looked at the source code for some of the other routers, but I just don't think that approach makes sense for tanstack router, but I guess I can get back to you on that.
Any and all help appreciated, I think the refine community would benefit tremendously from this.
Beta Was this translation helpful? Give feedback.
All reactions