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:
Solution:Jump to solution
I FIXED IT! Stupid mistake, I wasn't marking the root page function that was performing the prefetch as
async
... i.e:
Broken:
```ts
export default function QueuePage() {...1 Reply
Solution
I FIXED IT! Stupid mistake, I wasn't marking the root page function that was performing the prefetch as
async
... i.e:
Broken:
Fix: