E2E Typesafety with route handlers next
Unanswered
Giant panda posted this in #help-forum
Giant pandaOP
Are people still using tRPC? Thinking about how to set up e2e typesafe endpoints in Next. I was gonna use Next server actions, but saw this:
Server Actions are designed for mutations that update server-side state; they are not recommended for data fetching. Accordingly, frameworks implementing Server Actions typically process one action at a time and do not have a way to cache the return value.
6 Replies
is there a reason you can't use the route handlers? https://nextjs.org/docs/app/building-your-application/routing/route-handlers and then do some zod schema validation on both the client and server to make sure it's typesafe?
@Giant panda Are people still using tRPC? Thinking about how to set up e2e typesafe endpoints in Next. I was gonna use Next server actions, but saw this:
> Server Actions are designed for mutations that update server-side state; they are not recommended for data fetching. Accordingly, frameworks implementing Server Actions typically process one action at a time and do not have a way to cache the return value.
If they started their project in t3 stack, they would continue using tRPC.
And yeah, server actions are originally designed for mutation
For the type safety of server actions, check out this
https://next-safe-action.dev/
https://next-safe-action.dev/
@sergiy.eth is there a reason you can't use the route handlers? https://nextjs.org/docs/app/building-your-application/routing/route-handlers and then do some zod schema validation on both the client and server to make sure it's typesafe?
Giant pandaOP
Yeah I suppose I could do that - was just curious what people do
@James4u If they started their project in t3 stack, they would continue using tRPC.
Giant pandaOP
I did not start my project with the t3 stack