Emre
Pre-rendering Error with TRPC useSuspenseQuery – "fetch failed" During Build
Summary
During the build process, the application attempts to pre-render the page containing the
Greeting
component. Since the component uses useSuspenseQuery
to call a TRPC endpoint, pre-rendering triggers the call and results in a "fetch failed" error because the route isn’t available during build time. Known workarounds—switching to useQuery
or using prefetch on the page component—prevent the error; however, these solutions are not acceptable in this case.
Code Samples
src/app/page.tsx
src/components/greeting.tsx
(using useSuspenseQuery
)
2 replies