TanStackT
TanStack3y ago
3 replies
brilliant-lime

Understanding whether a fetch is made on the server

Hi there,

Sorry if this is a noob question. I have a call that I only intend to make client-side (don't want it during SSR) and am trying to figure out whether a fetch is being made.

export const useUser = () => {
    const getCurrentUser = trpc.auth.getCurrentUser.useQuery(undefined, {
        refetchOnWindowFocus: false
    });

    console.log(getCurrentUser.isFetching);

    return {
        ...getCurrentUser,
        user: getCurrentUser.data
    };
};


I can see that during SSR isFetching gets set to true, which implies I am making an unneeded fetch on the server? I don't want to use hydration or initialData or anything for this one, just make the call client-side.
Was this page helpful?