trpc / next-13

experimental playground for tRPC + next.js 13

Home Page:https://rsc.trpc.io

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

tRPC 10 with Next 13 App dir

jacobgad opened this issue · comments

Thank you to anyone who takes the time to respond or share their thoughts on this matter.
With the condition that the app folder was used exsclusevly with client components (to gain access to the nested layouts feature),
is there a way to setup tRPC 10 to work in the app dir?

Thanks again

@jacobgad I have started a new project with create-t3-app, I'm waiting for the same as you.

is there any way to make trpc routes inside app dir (using Route Handlers), its works inside pages/api but not in app/api..

There is an example of this working.

repo: https://github.com/devietti/trpc-next13-app
by: @devietti

The TLDR is: It uses the fetch adapter instead of the next adapter and adds an additional layer in the trpc client (instead of using /app/api/[trpc].ts he uses /app/api/[trpc]/route.ts

Worked for me, hope it helps.

Props to @devietti