Tutorial for setting up tRPC with Next13 app dir?
Anyone has a goos tutorial (blogpost / YouTube) on setting up tRPC with Next13 app dir for both client components as well as server components?
I have tried for the entire day and couldn't find a way to make it work... :/
1 Reply
I'm messing around with the new app dir. Here's what I'm doing so far.
I use server-side caller in server components (not passing hydrated state to React Query for now): https://trpc.io/docs/server/server-side-calls
For forms and client-side, instead of the Next.js server actions and foregoing progressive enhancement, I use the React Query integration (without the @trpc/next package) created in a client component that is wrapped around the root layout and react-hook-form as normal: https://trpc.io/docs/reactjs/setup
For trpc api route, I use the fetch adapter in app dir. Example: