What problem does it solve?
This Skill addresses the complexity of implementing and maintaining robust server-state management in React applications using TanStack Query v5, covering data fetching, caching, and synchronization.
Core Features & Use Cases
- Query key factories: Create structured, hierarchical keys to ensure accurate cache invalidation.
- Data transformation & select: Transform data in the query function or via select for optimized renders.
- Mutations & optimistic updates: Implement mutations with cache updates and rollback strategies.
- Authentication integration: Handle token refresh and protected queries with enabled flags.
- Testing & MSW: Mock server responses for reliable unit/integration tests.
- Suspense integration: Use first-class Suspense hooks for cleaner components.
Quick Start
Install TanStack Query v5, wrap your React app with a QueryClientProvider, and create a simple useQuery hook. Then progressively adopt mutations, select-based transforms, prefetching, suspense, and test utilities with MSW as needed.