Configures a TanStack Query client with caching, retry, and key factories for React apps.
// Source: https://github.com/mangeshraut712/Gravity-SaaS-Agent | License: MIT | Copyright 2026 Gravity AI
// Provided via justclaw.it.com; keep this notice with the code.
/**
* React Query Client Configuration
* Optimized for performance with caching and stale-while-revalidate strategy
*/
import { QueryClient } from '@tanstack/react-query';
export const queryClient = new QueryClient({
defaultOptions: {
queries: {
// Data stays fresh for 5 minutes
staleTime: 5 * 60 * 1000,
// Cache data for 10 minutes
gcTime: 10 * 60 * 1000,
// Retry failed requests 3 times with exponential backoff
retry: 3,
retryDelay: (attemptIndex: number) => Math.min(1000 * 2 ** attemptIndex, 30000),
// Refe
... (truncated -- full source via MCP)
See the full source, get the GitHub permalink, and search for more like it.
Get a free API key