tanstack-query-best-practices
TanStack Query best practices for optimized data fetching, caching, mutations, and server state management in React.
- Covers 32 rules across 10 categories: query keys, caching strategies, mutations, error handling, prefetching, infinite queries, SSR integration, parallel queries, performance optimization, and offline support
- Each rule includes explanation, anti-patterns, recommended implementations, and contextual guidance for when to apply
- Prioritized by impact: critical rules prevent cache bugs and data inconsistencies; high-priority rules ensure data integrity and UI consistency
- Organized with hierarchical query key factories, targeted cache invalidation, optimistic updates with rollback context, and structural sharing patterns
TanStack Query Best Practices
Comprehensive guidelines for implementing TanStack Query (React Query) patterns in React applications. These rules optimize data fetching, caching, mutations, and server state synchronization.
When to Apply
- Creating new data fetching logic
- Setting up query configurations
- Implementing mutations and optimistic updates
- Configuring caching strategies
- Integrating with SSR/SSG
- Refactoring existing data fetching code
Rule Categories by Priority
More from deckardger/tanstack-agent-skills
tanstack-start-best-practices
TanStack Start best practices for full-stack React applications. Server functions, middleware, SSR, authentication, and deployment patterns. Activate when building full-stack apps with TanStack Start.
5.9Ktanstack-router-best-practices
TanStack Router best practices for type-safe routing, data loading, search params, and navigation. Activate when building React applications with complex routing needs.
3.4Ktanstack-integration-best-practices
Best practices for integrating TanStack Query with TanStack Router and TanStack Start. Patterns for full-stack data flow, SSR, and caching coordination.
1.4K