TanStackT
TanStack2y ago
9 replies
clean-aquamarine

Error: Server Functions cannot be called during initial render. This would create a fetch waterfall.

I am trying to use a prefetch in my page (SSR) and then a useSuspenseQuery in my client component to call the same queryOptions

Unfortunately NextJS is complaining about using my function (getThread) as a "use server" function in the initial rendering. One workaround would be to export it twice and wrap it under a "use server" when fetching in client and as "only-server" when SSR. But this is gonna generate a lot of boilerplate.

Any suggestion about best approach to handle this? :prayge:
Was this page helpful?