tanstack-query

Manage server-state fetching, caching, and synchronization in React applications.

3|Updated May 11, 2026
One-click install
npx skills add https://github.com/JeromyJSmith/lattice-platform --skill tanstack-query-jeromyjsmith
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: tanstack-query
Source: https://github.com/JeromyJSmith/lattice-platform/tree/main/.agents/skills/skills/tanstack-query
Command: npx skills add https://github.com/JeromyJSmith/lattice-platform --skill tanstack-query-jeromyjsmith

SYSTEM DOCUMENTATION & REQUIREMENTS

What problem does it solve?

TanStack Query removes the complexity of fetching, caching, synchronizing, and updating server-backed data in your app.

Core Features & Use Cases

  • Server-state fetching with caching: Fetch and cache data with automatic stale/refresh behavior for predictable UI updates.
  • Invalidation and background refetching: Keep data in sync by invalidating query keys after changes.
  • Mutations with optimistic updates: Update the UI immediately while rolling back safely on errors.

Use case: In a runtime dashboard, you can fetch operator lists (queries), run actions that change entities (mutations), and automatically refresh dependent views by invalidating hierarchical query keys.

Quick Start

Install @tanstack/react-query, create a QueryClient, and wrap your app in QueryClientProvider so you can call useQuery with a queryKey and queryFn.

Frequently Asked Questions about tanstack-query

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

FAQPage Schema
How do I fetch and cache server-state data in React?

To fetch and cache server-state data in React, configure a QueryClient, wrap your app in QueryClientProvider, and use the useQuery hook with a queryKey and queryFn. This provides automatic stale and refresh behavior for predictable UI updates.

What is the best way to keep cached async data in sync after a mutation?

To keep cached async data in sync after a mutation, use query invalidation on hierarchical query keys. Invalidating specific query keys automatically triggers background refetching to update dependent views with the latest server-state data.

How do I implement optimistic updates for UI mutations in React?

Implement optimistic updates for UI mutations by applying mutation lifecycle patterns that update the UI immediately while safely rolling back changes on errors. This ensures a responsive user experience during server-state synchronization.

Can I use TanStack Query for paginated lists and infinite scrolling in React?

Yes, you can use TanStack Query for paginated lists and infinite scrolling. It manages server-state synchronization for these scenarios by handling query keys and query functions with cancellation via signal to maintain consistent cached data.

When do I need query functions with cancellation via signal for async data fetching?

You need query functions with cancellation via signal when fetching async server-state data in React to prevent race conditions. This pattern ensures outdated network requests are properly canceled when new queries are triggered or components unmount.