query-client.ts 576 B

1234567891011121314151617
  1. // lib/query-client.ts
  2. import { QueryClient } from "@tanstack/react-query";
  3. // Define constants that can be imported elsewhere
  4. export const CACHE_TTL = Infinity; // 5 minutes in milliseconds
  5. // Create a QueryClient with default options
  6. export const queryClient = new QueryClient({
  7. defaultOptions: {
  8. queries: {
  9. staleTime: CACHE_TTL, // Use the same value as in your hooks
  10. gcTime: CACHE_TTL, // Use the same time for garbage collection
  11. refetchOnWindowFocus: false, // Don't refetch when window regains focus
  12. refetchOnMount: false,
  13. },
  14. },
  15. });