tanstack-query-best-practices

Implement TanStack Query patterns for data fetching and caching in React applications.

567|82|Updated Mar 15, 2026
One-click install
npx skills add https://github.com/pedronauck/skills --skill tanstack-query-best-practices-pedronauck
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: tanstack-query-best-practices
Source: https://github.com/pedronauck/skills/tree/main/skills/tanstack-query-best-practices
Command: npx skills add https://github.com/pedronauck/skills --skill tanstack-query-best-practices-pedronauck

SYSTEM DOCUMENTATION & REQUIREMENTS

💡 This Skill includes references (resource) components.

What problem does it solve?

This Skill addresses the complexities of managing server state in React applications, ensuring efficient data fetching, caching, and mutation handling to prevent common bugs and performance issues.

Core Features & Use Cases

  • Optimized Data Fetching: Implements best practices for query keys, caching strategies, and error handling.
  • Efficient Mutations: Guides on using mutations for data updates, including optimistic updates and error rollback.
  • Performance Tuning: Provides rules for prefetching, parallel queries, and SSR integration to enhance user experience.
  • Use Case: When building a dashboard that displays real-time user data, posts, and comments, applying these best practices ensures smooth data loading, instant UI feedback on updates, and resilience against network errors.

Quick Start

Apply the tanstack-query-best-practices skill to refactor the data fetching logic in the user profile component.

Frequently Asked Questions about tanstack-query-best-practices

High-intent search queries and answers about installing and using this skill.

FAQPage Schema
How do I structure TanStack Query keys for efficient data fetching and caching?

TanStack Query keys should be structured as hierarchical arrays to optimize data fetching and caching. This structure ensures precise cache invalidation and synchronization of server state across your React application components.

What is the best way to handle optimistic updates and error rollback with React Query mutations?

The best way to handle React Query mutations is by implementing optimistic updates for instant UI feedback, combined with error rollback mechanisms. This ensures seamless data updates and resilience against network failures.

Does TanStack Query support SSR integration and parallel queries for performance tuning?

TanStack Query supports Server-Side Rendering (SSR) integration and parallel queries to enhance application performance. These features allow efficient data prefetching and synchronized loading of multiple data sources.

When do I need prefetching and infinite queries in React applications?

You need prefetching and infinite queries when building dynamic interfaces like real-time dashboards. These techniques ensure smooth data loading and enhanced user experiences by fetching data before it is visibly required.

Why does my server state synchronization fail during offline support in React Query?

Server state synchronization fails during offline support if caching strategies and error management are not properly configured. Applying comprehensive guidelines for offline support ensures resilience and proper data consistency.