tanstack-query

Manage React server state with TanStack Query v5 data fetching and caching.

6|1|Updated Feb 27, 2026
One-click install
npx skills add https://github.com/RepairYourTech/cfsa-antigravity --skill tanstack-query-repairyourtech
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: tanstack-query
Source: https://github.com/RepairYourTech/cfsa-antigravity/tree/main/.agent/skill-library/stack/state/tanstack-query
Command: npx skills add https://github.com/RepairYourTech/cfsa-antigravity --skill tanstack-query-repairyourtech

SYSTEM DOCUMENTATION & REQUIREMENTS

💡 This Skill includes scripts (resource) and references (resource) components.

What problem does it solve?

This Skill simplifies managing server state in your React applications, handling data fetching, caching, mutations, and synchronization with the server.

Core Features & Use Cases

  • Declarative Data Fetching: Define data needs with useQuery and let TanStack Query manage fetching, caching, and background updates.
  • Mutations & Cache Updates: Easily handle data modifications with useMutation, including optimistic updates and cache invalidation.
  • Infinite & Paginated Queries: Implement seamless infinite scrolling and pagination for large datasets.
  • SSR & Hydration: Integrate with server-side rendering frameworks like Next.js for a smooth initial load.
  • Use Case: Build a dashboard that displays real-time user data, allows users to update their profiles, and fetches posts with infinite scrolling, all while ensuring data is always fresh and UI is responsive.

Quick Start

Use the tanstack-query skill to set up the QueryClientProvider in your React application.

Frequently Asked Questions about tanstack-query

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

FAQPage Schema
How do I manage server state and data fetching in React applications?

Server state in React is managed using TanStack Query to handle data fetching, caching, mutations, and synchronization. It provides declarative data fetching with useQuery and ensures data remains fresh through background updates.

How do I set up TanStack Query for data fetching in my React project?

To set up TanStack Query, configure the QueryClientProvider in your React application. This allows you to define data needs with useQuery and manage data modifications with useMutation.

Does TanStack Query work with Next.js for server-side rendering?

Yes, TanStack Query works with Next.js for server-side rendering. It supports SSR hydration to provide a smooth initial load when integrating with modern React frameworks.

What is the best way to implement infinite scrolling and pagination in React?

The best way to implement infinite scrolling and pagination is using TanStack Query's infinite queries feature. It allows you to fetch large datasets seamlessly and manage cached pages efficiently.

How do I handle optimistic updates and cache invalidation for React mutations?

Optimistic updates and cache invalidation are handled using the useMutation hook in TanStack Query. This allows you to easily handle data modifications while keeping the UI responsive and synchronized.

Why use TanStack Query instead of global state management for React server data?

You should use TanStack Query instead of global state management because it specifically manages server state with robust error handling and type-safe API interactions. It handles background updates and caching automatically.