TanStack Query Config Builder
Configure your TanStack Query (React Query v5) setup visually. Set staleTime, gcTime, retry logic, and generate production-ready TypeScript code for your QueryClient and hooks.
Presets
Cache Timing
Query Settings
Cache Lifecycle
Generated Code
Frequently Asked Questions
What is TanStack Query (React Query)?▼
TanStack Query is an async state management library for React (and other frameworks). It handles fetching, caching, background updates, and synchronization of server state. Instead of manually managing loading/error/data state with useState and useEffect, you call useQuery and let the library handle everything.
What is staleTime?▼
staleTime is how long (in ms) fetched data is considered fresh. During this window, React Query won't refetch the data — it serves the cached version. After staleTime expires, data is considered stale, and React Query will refetch when the query is re-used (e.g., on window focus or component mount).
What is gcTime (formerly cacheTime)?▼
gcTime (garbage collection time) is how long inactive query data stays in memory after all components using it unmount. Once gcTime expires, the cache entry is removed. gcTime should always be ≥ staleTime. Default is 5 minutes. Setting it to Infinity keeps data in memory until page reload.
When should I use initialData vs placeholderData?▼
initialData is treated as real data — it counts as a successful cache entry, respects staleTime, and won't trigger a background fetch if still fresh. placeholderData is UI-only — it's shown while the query loads but never persisted to the cache. Use initialData for SSR-hydrated data, placeholderData for skeleton/preview content.
What does retry do?▼
retry controls how many times React Query retries a failed request before marking the query as error state. Default is 3. Each retry uses exponential backoff (retryDelay). Set to false to disable retries (useful for user-input queries where immediate feedback is needed).
How do I use QueryClient globally?▼
Create a QueryClient instance outside your component tree and pass it to QueryClientProvider at your app root. You can access it with useQueryClient() hook inside components for manual invalidation, prefetching, or setting cached data. For SSR/Next.js, create a new QueryClient per request to avoid shared state between users.
Related Products
on GumroadDevPlaybook Interview Vault
210+ real technical interview questions with model answers, asked at Google, Meta, Amazon, Microsoft, Stripe, and Shopify. Covers Frontend (55), Backend (55), System Design (50), and DSA (50). Available in English and Traditional Chinese.
Buy on Gumroad →TypeScript Quick Reference Toolkit
5 practical reference files for TypeScript developers: cheatsheet, TS vs JS comparison, 20 utility types with real examples, tsconfig best practices template, and 15 common mistakes guide. Print it. Keep it on your desk.
Buy on Gumroad →Developer Interview Vault
210 technical interview questions with model answers, key points, and follow-up questions. Covers Frontend, Backend, System Design, and DSA — bilingual English + Traditional Chinese (ZH-TW). PWYW from $29.
Buy on Gumroad →You Might Also Need
SQL to TypeScript Types
Convert SQL CREATE TABLE statements to TypeScript interfaces and Zod schemas. Maps SQL column types to TypeScript with nullability.
Open free tool →
TypeScript Discriminated Union Builder
Build TypeScript discriminated unions visually. Add variants with fields and get type-safe switch statements, type guards, and exhaustive checking code.
Open free tool →
React Native StyleSheet Generator
Generate React Native StyleSheet.create() code from CSS-like input. Convert web CSS to React Native styles with proper camelCase properties and number values.
Open free tool →
More Free Tools
Related Articles
React 19: Complete Guide to New Features in 2026
Everything new in React 19: use() hook, Actions, optimistic updates, ref as prop, form actions, and the React Compiler. Production-ready patterns with TypeScript examples.
SolidJS vs React 2026: Performance, DX, and When to Choose Each
Deep comparison of SolidJS and React in 2026: fine-grained reactivity vs virtual DOM, signals vs useState, performance benchmarks, SolidStart vs Next.js, and honest real-world tradeoffs.
TanStack Query vs SWR vs RTK Query: React Data Fetching 2026
A deep comparison of TanStack Query, SWR, and RTK Query for React server state management in 2026 — caching, background refetch, optimistic updates, bundle size, and TypeScript support.
Frontend Interview Questions 2026: React, TypeScript & More
The most common frontend interview questions in 2026 with detailed answers covering React, TypeScript, performance, accessibility, and system design.
Building Type-Safe APIs with tRPC and Zod in 2026
Complete tRPC + Zod tutorial: set up end-to-end type-safe APIs with zero code generation. Includes routers, middleware, input validation, error handling, and React Query integration.
Enjoying this tool? Get more like it.
Weekly developer tool guides, productivity playbooks & AI tricks. Free. No spam.
Unlock AI-Powered Dev Tools
- ⚡ AI Code Review, Doc Generator & SQL Builder
- ⚡ All premium templates & early access
- ⚡ Member discounts on Gumroad products
$9/mo after trial · Cancel anytime
Want the full toolkit?
Get DevPlaybook Pro
Every template, guide, boilerplate, and automation script in one bundle. 13 premium products — grab them all at once and save big.
MIT licensed · Instant download · No subscription
See what's included → Browse all deals →