Benefits of using tPRC when we have createServerFn()
The title says it all, i am curious to if there are any real benefits of using tRPC with TanStacj Start - since it already offers server actions that are easily integrated with Tanstack Query.
What are your views on this?
3 Replies
absent-sapphire•3mo ago
imo server fns are enough if your backend isnt being used by other apps.
if you have other apps (like a mobile app) that has to use your Start backend, you'd have to use API/Server Routes and you lose the typesafety
trpc gives you typesafe experience of server fns, and flexibility of api/server routes so you can use them outside your Start app
I also find setting up tRPC to be painful so I wonder if the team has plans to unify api routes and functions. and maybe generate an openapi schema for external typesafety
absent-sapphire•3mo ago
yeah this couldve been nice and i think it was actually planned before: https://discord.com/channels/719702312431386674/1371243165331357757
but now we can just call server functions from api routes or use something like hono
yappiest-sapphire•3mo ago
I was trying to stick to server fns alone and I ended up giving up. The loader is cool and all but does give you the control I was hoping for to develop reactive apps client side. For me the breaking point was something as simple as having the page show a loading skeleton for rows while loading the next page on a paginated table