TRPC NextJS Context - Middleware Reload?
Howdy! We know the beloved T3 stack with
Thank you kindly.
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
did you get anywhere here?
Hi @eula1 , I have not, and am still actively researching
hey @eula1. , any luck?
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.
Thanks! Will check it out
What do you think about just replacing trpc with server actions? @pineappaul
I think that is the way to go unless you require having a separate API to do something like serve a mobile app
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
do you think it is OK for your build to have the API tightly coupled with the NextJS app?