Next.js App router
Hello, is there any official way to implement tRPC with app router, or is it still experimental, according to the example app repo I came across?
Any guidance would be appreciated 🙂
Thanks.
5 Replies
tRPC + app router is stable :)
You can read here how to set up the client: https://trpc.io/docs/client/tanstack-react-query
ty for that, only asking as it seems like their nextjs example repo has a giant banner that warns against using it in production.
bumping this, https://trpc.io/docs/server/adapters/nextjs is this only required for pages router? Assuming with app-router,
trpc/server
and trpc/client
are sufficient enough? especially if pairing with react-query?Next.js Adapter | tRPC
tRPC's support for Next.js is far more expansive than just an adapter. This page covers a brief summary of how to set up the adapter, but complete documentation is available here
Yeah, I think you only need that adapter if you want to set up tRPC in the pages router as API routes.
If you're using the app router, just use the fetch adapter as described at the bottom of the page.
If your tRPC is integrated into Express/Hono etc, you just need to set up your client in Nextjs
cheers 🙂 awesome 😎