TRPC NextJS Context - Middleware Reload?

Howdy! We know the beloved T3 stack with app directory is now a streamlined thing, but there's a peculiarity with Clerk and TRPC. After signing in with Clerk, authenticated requests can only be made to the TRPC server after the user refreshes the page. Once the page is refreshed, authenticated requests to protected procedures work just fine. Reckon this is due to the root layout not re-running on the server, but could be totally off base there. Happy to open a thread and provide the actual implementation of the middleware as grabbed directly from the Next13 starter!
Thank you kindly.
7 Replies
carnegiepilled
carnegiepilled14mo ago
did you get anywhere here?
pineappaul
pineappaulOP14mo ago
Hi @eula1 , I have not, and am still actively researching hey @eula1. , any luck?
pineappaul
pineappaulOP14mo ago
here is my current implementation of tRPC + Clerk + Next app router if you want to see what we have for at least getting it working https://github.com/paulmikulskis/popup
GitHub
GitHub - paulmikulskis/popup
Contribute to paulmikulskis/popup development by creating an account on GitHub.
carnegiepilled
carnegiepilled14mo ago
Thanks! Will check it out What do you think about just replacing trpc with server actions? @pineappaul
pineappaul
pineappaulOP14mo ago
I think that is the way to go unless you require having a separate API to do something like serve a mobile app
carnegiepilled
carnegiepilled14mo ago
yeah i saw this pattern on a blog somwhere and i really like it i think im ditching trpc will let you know how it goes
pineappaul
pineappaulOP14mo ago
do you think it is OK for your build to have the API tightly coupled with the NextJS app?
Want results from more Discord servers?
Add your server