What would you recommend?
What would you guys recommend when building an application? Going with something like trpc + react query, or going just with server components?
2 Replies
I have mix of both and works great for my use cases.
So entry point of the page will be a server component. Trpc for server components does the API fetch and gets all require data.
For mutations, it will be a client component and i use usemutation from trpc for post requests.
I now try to go by default server component + server actions, and then build internal APIs with tanstack query only if needed (I try to avoid at all costs). If there are too many internal APIs, because sometimes you just don't have a choice, then I'll consider TRPC, but something to keep in mind, TRPC is great for query and mutation as long as it is internal, if you plan to give this API access to users, then avoid TRPC.
So, depending on your needs, try to have an idea of the number of internal APIs for query you will need, if it's significant trpc, if not server component is fine