shovancak
shovancak2y 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
Nick2y 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
shovancak
shovancak2y 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
Nick2y ago
Yep, that’s your trade off
shovancak
shovancak2y ago
Thank you 👍
mossotron
mossotron2y 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...