Google Sheets API request in NextJS App router
I'm developing a NextJS app (v14) with server components, integrating React Query.
I've set up the QueryClient Provider for SSR and client-side caching (https://tanstack.com/query/latest/docs/framework/react/guides/advanced-ssr).
When I log the request in the query function, it successfully fetches data.
My server-side component (
layout.tsx):
But, when I use the useQuery hook in the client-side like so:
I get this error
Overview | TanStack Query Docs
TanStack Query (FKA React Query) is often described as the missing data-fetching library for web applications, but in more technical terms, it makes fetching, caching, synchronizing and updating server state in your web applications a breeze.
Motivation
1 Reply
like-goldOP•2y ago
...
Here is the
getGoogleSheetsData request:
Of course, I don't want this to run on the client, and I KNOW it runs on the server perfectly fine. This error suggests the request is running on the client side. What have I done wrong?