Luke
Explore posts from serversClarification on inconsistency between React Query + tRPC docs with serialization
Hey everyone, I have a quick question. I have been exploring using different serialization methods + learning more about tRPC / React Query as a whole.
In my deep dive on the React Query docs, specifically on the Server Rendering & Hydration Serialization section, they mention that superjson is unsafe to use on the server, and recommend using devalue instead. See here, last paragraph: https://tanstack.com/query/latest/docs/framework/react/guides/ssr#serialization
But then, in the tRPC docs, it actually says the opposite, almost verbatim: https://trpc.io/docs/server/data-transformers#different-transformers-for-upload-and-download
Can anyone clarify for me here?
2 replies
TTCTheo's Typesafe Cult
•Created by Luke on 7/23/2024 in #questions
Next.js/tRPC Prefetch w/ HydrateClient "Error occurred prerendering page"
Hello all, I'm trying to get to the bottom of an issue I'm having using prefetching with HydrateClient. I'm using the t3 stack, so I believe that HydrateClient is a helper function wrapping tRPC
helpers.dehydrate()
...
When I run this code with pnpm dev
, it works fine, but when I go to pnpm build
, I am getting
Here is the minimum example that I was able to reproduce with:
And the Queue component:
I've tried using both useSuspenseQuery and useQuery in the client component. I'm not sure what I'm doing wrong! Would love to figure out prefetching.
Relevant Versions:
4 replies
Next.js/tRPC Prefetch w/ HydrateClient "Error occurred prerendering page"
Hello all, I'm trying to get to the bottom of an issue I'm having using prefetching with HydrateClient. I'm using the t3 stack, so I believe that HydrateClient is a helper function wrapping tRPC
helpers.dehydrate()
...
When I run this code with pnpm dev
, it works fine, but when I go to pnpm build
, I am getting
Here is the minimum example that I was able to reproduce with:
And the Queue component:
I've tried using both useSuspenseQuery and useQuery in the client component. I'm not sure what I'm doing wrong! Would love to figure out prefetching.
Relevant Versions:
4 replies
tRPC useQuery with skipToken
I am trying to implement a useQuery which only happens once. I haven't been happy with setting enabled so something like
But... following their example nearly identically doesn't work for me. Broken Example Router And my error: Am I meant to define the skipToken in the zod input? It seems counter-intuitive to have to define skipToken in the zod input every single time this needs to be used on a route. P.S. I have a feeling this is a bug on tRPC itself given how little documentation and conversation surrounds the usage of skipToken on Discord and GitHub.
enabled: !!foo
as it'll still refetch, etc (and yes I know you can disable certain refetches, but that's not the goal here).
I found a supported, type-safe solution on the tRPC docs (https://trpc.io/docs/client/react/disabling-queries).But... following their example nearly identically doesn't work for me. Broken Example Router And my error: Am I meant to define the skipToken in the zod input? It seems counter-intuitive to have to define skipToken in the zod input every single time this needs to be used on a route. P.S. I have a feeling this is a bug on tRPC itself given how little documentation and conversation surrounds the usage of skipToken on Discord and GitHub.
4 replies