T
TanStack•9mo ago
wise-white

How are Server function URL's determined, will it break when changing name or location?

What happens if a server function is renamed, or relocated, I guess the server function url signature is changed then, hence breaking older clients still running in the browser. Couldn't this be fixed by allowing API routes to target a server function? Then we decouple the url signature from the function, giving more structure, decoupling while having less magic. Instead we could make a similar RPC solution as Hono has for the API routes, i.e. importing the type to the client and with a small wrapper allowing for type save path structuring of the api route.
8 Replies
deep-jade
deep-jade•9mo ago
yes if you rename a server function the url might change.
wise-white
wise-whiteOP•9mo ago
I can't wrap by head around that, yet. From the current way of working (without server actions, i.e. just defined url's, like the API routes) it seems like a step back: - Less clear in monitoring / logging systems as urls won't be clearly readable and have to be looked up (if even possible to look it up somewhere as there is no overview of them) - Sudden tight coupling between the function itself (location/name) and where you call it from (client) - Less clear development through (e.g. network inspect in browser) as urls are now non human readable. And what is the advantage vs just be able to add a route to the server function?
deep-jade
deep-jade•9mo ago
you can have as many server functions as you want. you might not want to name them all. but I agree that setting the url optionally would be nice
wise-white
wise-whiteOP•9mo ago
Well to be fair, I would like to name them all, there are many system that rely on the url (aside from being easier to interpret a route). I don't see a reason for a magical non-human-readable URL, but curious to hear the reason of thought behind it as most TanStack products do things for a reason...
adverse-sapphire
adverse-sapphire•9mo ago
RPCs in the full stack world traditional are not public URLs But I agree, having an optional public URL is on our list It's simply easier for people to reason about initially if they are not required to assign unique urls to each function
united-yellow
united-yellow•9mo ago
That would be really good, even other apps could use that friendly public url to point to an specific server function šŸ˜
adverse-sapphire
adverse-sapphire•9mo ago
With our new server function plugin I’m working on this is even closer to a possibility
wise-white
wise-whiteOP•9mo ago
That's great to hear! Will be keeping a close eye on it, any issue / PR i can follow? I'm all in for quickly making robust applications, and since last year I got excited with Hono and it's RPC functionality (not inventing new paradigms, but smoothing the current experience so much that in my experience it's better than most frameworks atm). TanStack Start offering similar functionality, while also making it easy to opt-in to React specific server functionality when needed, will be very cool! I'm not yet sold on RSC's and the Nextjs philosphy of doing everything on the server, so looking forward to how TanStack Start will turn out!

Did you find this page helpful?