hov_s
hov_s3y ago

createTRPCNext and createTRPCProxyClient within one NextJs app

Hey, Is there any possibility to use createTRPCNext and createTRPCProxyClient clients in one NextJs app? I have a use-case where I need to use a vanilla client to fetch data in my app but I don't want to lose the possibility of using useQuery and useMutation hooks in my components.
6 Replies
Nick
Nick3y ago
You can use both, it might be a code smell if there’s a better way but they shouldn’t conflict with each other
hov_s
hov_sOP3y ago
But what about things like caching or query invalidation? Client created by createTRPCProxyClient use tenstack react query it is handled out of the box 🤔. This can be problem in case of vanilla client
Nick
Nick3y ago
Yep, that’s your trade off
hov_s
hov_sOP3y ago
Thank you 👍
jamesmoss
jamesmoss3y ago
Im also running into this issue today, would be cool if there was a way you could pass the client created from createTRPCProxyClient into createTRPCNext so you're sharing the instance between them. Or better, a way to access the underlying trpc client created by createTRPCNext
Alex / KATT 🐱
GitHub
Allowing prefetch outside of component but still client-side? · trp...
I was trying out the new tanstack router and trying to integrate it with tRPC. This works fine, but I also want to use the loader function of tanstack router to prefetch the data to prevent some wa...

Did you find this page helpful?