Do we still need RPC libraries when we have Server Actions?
Answered
Asari posted this in #help-forum
AsariOP
I've been trying to understand how SAs differ from say tRPC but can't understand it. I only have experience with REST APIs so this whole thing is new to me so I probably just don't understand something?
Answered by joulev
Yeah I’d say you don’t need other RPCs since server actions are themselves already an RPC. tRPC has some features that server actions don’t have, for example runtime validation, so you need to fill in the gap
7 Replies
Yeah I’d say you don’t need other RPCs since server actions are themselves already an RPC. tRPC has some features that server actions don’t have, for example runtime validation, so you need to fill in the gap
Answer
AsariOP
Don't they suggest using Zod for that or do mean some other validation?
Important to note that SAs are tightly integrated with the router, while other RPCs such as tRPC aren’t. That gives a decisive advantage for SAs over other RTCs
@Asari Don't they suggest using Zod for that or do mean some other validation?
Zod is good, but are is any other validation libs. You are free to use anything that you know
Even simple if else without any libraries work too
AsariOP
Yep, I'll probably go with Zod simply because I have no reason not to and it seems the most popular. Plus I'm thinking of using Drizzle which offers drizzle-zod component.
But thanks. I was looking at the examples in nextjs.org and some examples with tRPC and just wondered what the catch is because they look so similar 🙂