React Query Data Fetching Patterns

Generate React Query/TanStack Query patterns for data fetching and caching

6/11/2026
Prompt
Create React Query patterns for:

Data Sources: {{DATA_SOURCES}}
Features: {{FEATURES}}
Cache Strategy: {{CACHE_STRATEGY}}

Generate complete React Query setup:

1. **Query Client Configuration:**
   - Default options
   - Cache time settings
   - Retry configuration
   - Error handling
   - DevTools setup

2. **Query Patterns:**
   - Basic query
   - Paginated query
   - Infinite query
   - Dependent queries
   - Parallel queries
   - Placeholder data

3. **Mutation Patterns:**
   - Basic mutation
   - Optimistic updates
   - Rollback on error
   - Cache invalidation
   - Related query updates

4. **Custom Hooks:**
   - useQuery wrappers
   - useMutation wrappers
   - Composed hooks
   - Type-safe hooks

5. **Cache Management:**
   - Manual invalidation
   - Prefetching
   - Cache persistence
   - Selective invalidation

6. **Error Handling:**
   - Error boundaries
   - Retry strategies
   - Global error handler
   - Error display patterns

7. **Loading States:**
   - Loading indicators
   - Skeleton loaders
   - Suspense integration
   - Progressive loading

8. **Testing:**
   - Mock query client
   - Testing hooks
   - MSW integration
   - Snapshot testing

9. **SSR/SSG:**
   - Hydration
   - Prefetching on server
   - Initial data
   - Cache serialization

Include TypeScript type inference patterns.

Or press ⌘C to copy

Variables (3)

Replace these placeholders with your own content before using the prompt.

[{DATA_SOURCES][{FEATURES][{CACHE_STRATEGY]

Ready to use?

Copy and paste into your favorite AI tool

Test this prompt live

Try it in our AI Playground with Claude

Open Playground

Explore more Coding prompts

Browse Coding

Command Palette

Search for a command to run...