trpc with nextjs 15

Does it makes sense using trpc with nextjs 15? Because there is server actions too but that's not type safe.
9 Replies
Salumsu
Salumsu2w ago
Server actions are type-safe though, can you explain why you think otherwise?
WiZtEk
WiZtEk2w ago
I’m also curious if there’s a reason to still use trpc in nextjs15 Even in the pages router
Aweed
AweedOP2w ago
So trpc doesn’t makes sense in app router?
Sameer
Sameer2w ago
Honestly, if someone is a bit skeptical about all these new fancy Next.js-related features, it's better to use tRPC. Prefetching on the server and using the server cache on the client is a really nice pattern. You kind of get the best of both worlds with that approach. Since tRPC integrates with TanStack Query, using it is also really simple.
And trust me, the end-to-end type safety that tRPC provides is beneficial any day. Server Actions are type-safe, but are they as simple to set up (For End-To-End Typesafety) and use as tRPC? I don’t know.
Plus, Server Actions are meant for mutations, not for fetching—they only support POST requests, not GET. Even the React team doesn’t recommend using them for fetching purposes. Prefetching on Server & use Cache on Client: Alex Sidorenko Tweet on this topic using SWR
Alex Sidorenko (@asidorenko_) on X
Moving data fetching between client and server with SWR
From An unknown user
X
Xanacas
Xanacas7d ago
I’ve worked quiet a lot with server actions and I like them much more than trpc because of their simplicity in DX. With serverrendering I had so far very rarely the case that I had to fetch client side - I think this remark is reasonable. I’d probably go with trpc just for fetch, if this would be needed.
Salumsu
Salumsu6d ago
It really depends on you. Other people might still prefer tRPC over server actions. I can't provide much value here since I'm no expert, but if you want simplicity, go for server actions.
Aweed
AweedOP6d ago
Understood all the things u said, so for a large scale ecommerce app trpc will do the work better? Right?
Sameer
Sameer6d ago
Yeah, for any large scale app, its better to have some amount of separation between frontend & backend. So, for a large scale ecommerce, I would prefer to keep my tRPC completely separated, a standalone backend with either express or fastify with a monorepo. Plus keeping your tRPC seperate as backend, it would be easier to use that, If we decide to have mobile/desktop-client/app, using react native/electron.
Aweed
AweedOP6d ago
I got it thanks u so much

Did you find this page helpful?