import { QueryClient } from '@tanstack/react-query' // Module-level singleton — shared across SSR hydration, tRPC, and all // components so mutations/invalidations hit the same cache. let queryClient: QueryClient | undefined export function getQueryClient() { if (!queryClient) { queryClient = new QueryClient({ defaultOptions: { queries: { staleTime: 30 * 1000, retry: 2, refetchOnWindowFocus: false, // Refetch when a screen remounts (navigating back to it) even within // staleTime — the web equivalent of native useMarkDataFetchers. refetchOnMount: 'always', }, }, }) } return queryClient }