$npx skillfedfor your agent

tanstack-query

TanStack Query provides asynchronous state management for server data across React, Vue, Solid, Svelte, and Angular. It handles caching, background synchronization, pagination, infinite scrolling, and optimistic updates automatically. Use queries for data fetching and mutations for server modifications, with lifecycle hooks for managing side effects and rollback scenarios.

TanStack Query manages server state with automatic caching, background refetching, and stale-while-revalidate patterns.

AI-generated summary based on this skill's SKILL.md

★ 30  1 MITupdated by tanstack-skills

Decision gist · record as of 2026-01-31

TanStack Query manages server state with automatic caching, background refetching, and stale-while-revalidate patterns. TanStack Query provides asynchronous state management for server data across React, Vue, Solid, Svelte, and Angular. It handles caching, background synchronization, pagination, infinite scrolling, and optimistic updates automatically. Use queries for data fetching and mutations for server modifications, with lifecycle hooks for managing side effects and rollback scenarios.

manual: git clone https://github.com/tanstack-skills/tanstack-skills → cp -r tanstack-skills/plugins/tanstack-query/skills/tanstack-query ~/.claude/skills/tanstack-query
plugins/tanstack-query/skills/tanstack-query/SKILL.md · version 1207687a

Use it when

  • TanStack Query caches fetched data by query key and automatically refetches in the background when data becomes stale.
  • Yes, TanStack Query provides useInfiniteQuery for load-more and infinite scroll patterns.

Verify before relying

Read SKILL.md below before installing (1 file). Open directory: indexed for reading, not audited.

Same gist for agents: .md · .json

Install

tanstack-skills/tanstack-skills/tanstack-query

Open directory. Skills are indexed for reading, not audited. Review a skill's body before installing it.

Frequently asked questions

AI-generated answers based on this skill's SKILL.md and metadata

What is tanstack query react data fetching and how does it work?

TanStack Query is an asynchronous state management library for server data in React and other frameworks. It automatically handles caching, background synchronization, and refetching. Use the useQuery hook to fetch data with automatic deduplication and stale-while-revalidate patterns, and useMutation for server modifications. TanStack Query manages the full lifecycle—loading, error, and success states—without manual Redux-like boilerplate.

How does react query caching and server state management work?

TanStack Query caches fetched data by query key and automatically refetches in the background when data becomes stale. Configure stale time and cache time to control when data is considered fresh or evicted. Query invalidation lets you manually trigger refetches after mutations. TanStack Query also supports window focus refetching and persistent cache storage, so your app stays synchronized with server state without constant manual updates.

Can tanstack query handle infinite scroll and pagination patterns?

Yes, TanStack Query provides useInfiniteQuery for load-more and infinite scroll patterns. It manages a paginated cache structure, tracks the last page cursor, and handles fetching new pages seamlessly. Combine it with intersection observers or scroll events to trigger page loads. TanStack Query also supports traditional offset-based pagination through query key variations and automatic cache merging.

What are optimistic updates and react query mutations?

TanStack Query's useMutation hook handles form submissions and server modifications. Optimistic updates let you update the UI immediately before the server responds, then roll back on error. Use the onMutate callback to update cache optimistically, onSuccess to confirm changes, and onError to revert. This pattern improves perceived performance and user experience in forms and real-time applications.

How do I set up typescript patterns with tanstack query?

TanStack Query is TypeScript-first. Define generic types for your query data and error responses: useQuery<DataType, ErrorType>(). Use typed query keys as const objects for better refactoring. Configure queryClient with default options for retry logic, stale time, and error handling. Leverage inference for mutations and dependent queries with enabled conditions to create type-safe, maintainable data-fetching layers.

What debugging and monitoring tools does tanstack query provide?

TanStack Query includes devtools for inspecting queries, mutations, and cache state in real time. Monitor query status, stale times, and refetch triggers. Enable persistence to store cache across sessions. Use lifecycle callbacks (onSuccess, onError, onSettled) for logging and analytics. These tools help debug race conditions, stale data issues, and background refetching behavior in development and production.

SKILL.md

Rendered from the published skill. Quoted content, verbatim.

Overview

TanStack Query (formerly React Query) manages server state - data that lives on the server and needs to be fetched, cached, synchronized, and updated. It provides automatic caching, background refetching, stale-while-revalidate patterns, pagination, infinite scrolling, and optimistic updates out of the box.

Package: @tanstack/react-query Devtools: @tanstack/react-query-devtools Current Version: v5

Installation

npm install @tanstack/react-query
npm install -D @tanstack/react-query-devtools  # Optional

Setup

```tsx import { QueryClient, QueryClientProvider } from '@tanstack/react-query' import { ReactQueryDevtools } from '@tanstack/react-query-devtools'

const queryClient = new QueryClient({ defaultOptions: { queries: { staleTime: 1000 * 60, // 1 minute gcTime: 1000 * 60 * 5, // 5 minutes (garbage collection) retry: 3, refetchOnWindowFocus: true, refetchOnReconnect: true, }, }, })

function App() { return (

(truncated - see the full file via the links below)

File tree — 1 file
plugins/tanstack-query/skills/tanstack-query/SKILL.md

Let your AI agent find skills like this

Example. Real query, live index.

You found this page by searching. An agent finds it by wishing: SkillFed indexes 56,283 agent skills by what they can do, searchable in plain language.

wish › “Manage server state with automatic caching and background refetching”

Give your agent the search over MCP, or paste the wish link into any chat. No install? Search from any chat →

Related skills

tanstack-query
by bobmatnyc · bobmatnyc/claude-mpm-skills

TanStack Query handles server-state fetching and caching in React applications, automating data synchronization and eliminating manual boilerplate. It provides built-in background refetching, optimistic mutations, intelligent cache invalidation, and pagination support for complex data workflows.

MITupdated Jul 2026
★ 62repo stars
accelint-tanstack-query-best-practices
by gohypergiant · gohypergiant/agent-skills

This skill covers expert patterns for TanStack Query in modern React with Next.js App Router, including QueryClient configuration, query key factories, cache invalidation, and optimistic updates. Learn critical anti-patterns to avoid—like singleton QueryClients on servers, unstable query keys, and N observers per list item—plus decision matrices for cache configuration and mutation strategies.

Apache-2.0updated Jul 2026
★ 21repo stars
App Renderer Systems
by pedronauck · pedronauck/skills

This skill teaches you how to structure and implement self-contained domain modules that own their API calls, data fetching, hooks, and components. It covers the mandatory directory layout, API service layer patterns, TanStack Query integration for queries and mutations, React context conventions, XState store setup, and public API organization. Use it when creating new systems, extending existing ones, or debugging system-layer code.

no license declared → metadata onlyupdated Jul 2026
★ 541repo stars
tanstack-query
by secondsky · secondsky/claude-skills

TanStack Query v5 handles server state management in React through data fetching, caching, and mutation patterns. Learn QueryClient setup, hook usage with the v5 object syntax, and common migration issues from v4.

MITupdated Jul 2026
★ 196repo stars
tanstack-query
by pproenca · pproenca/dot-skills

TanStack Query Best Practices provides 40 prioritized rules across 8 categories to optimize data fetching, caching strategies, and query patterns in v5 applications. Covers query key structure, cache configuration, mutation handling, prefetching, infinite queries, Suspense integration, error handling, and render optimization.

MITupdated Jul 2026
★ 182repo stars
Tanstack Query
by oakoss · oakoss/agent-skills

TanStack Query is an async state manager that handles server data fetching, caching, and synchronization in React applications. It automates cache invalidation, deduplication, background updates, and stale data management—you supply a queryFn that returns a Promise, and the library handles the rest. Use it for infinite scrolling, offline-first apps, complex cache strategies, and hybrid server/client architectures.

no license declared → metadata onlyupdated Mar 2026
★ 13repo stars

More skills react-query-best-practices (MIT) · tanstack-query (Apache-2.0) · senior-frontend (MIT) · bug-fix-tdd (Apache-2.0) · tanstack-devtools (MIT) · Tanstack Integration (unlicensed) · state-management (MIT) · tanstack-table (MIT)

Tags
server-state-synccache-invalidationbackground-pollingoptimistic-uirequest-deduplicationoffline-firstssr-hydrationquery-cancellationstale-data-handling