TanStackT
TanStack16mo ago
4 replies
inadequate-blush

Always fetch on the server?

How can I fetch my data on the server and not on the client on my Next.js app? Maybe I am just dump but I could not get it from the docs. Defining the Query Client forces the page to be an client component. But how can I then fetch on the server and have the advantage of e.g. env variables and don't have to reveal the API endpoint to the client. It is not logical to me to transform everything to an client component with the Query Client definition when I want to fetch on the server. Also I want to keep as many components as possible server side rendered. Hope you can help me with that.
Was this page helpful?