T
TanStack•2mo ago
sunny-green

How to run the `queryFn` only on the server and not on browser at all?

I was able to do this with server functions and defer the fetching till the component gets mounted (to avoid fetching at initial render), but somehow i get the error -
Nextjs Warning: Cannot update a component (`Router`) while rendering a different component (`Home`). To locate the bad setState() call inside Home
Nextjs Warning: Cannot update a component (`Router`) while rendering a different component (`Home`). To locate the bad setState() call inside Home
1 Reply
sunny-green
sunny-greenOP•2mo ago
I dont want to prefetch data as well, because I need to fetch the data on request basis not on build time, so the initial page load will be terribly affected, so no prefetching Ok, I removed all the Suspense shenanigans and it seems to work just fine 🤔

Did you find this page helpful?