tanstack-query

Fetch and cache server data with useQuery and useMutation patterns.

Updated Apr 5, 2023
One-click install
npx skills add https://github.com/fcalell/dotfiles --skill tanstack-query-fcalell
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: tanstack-query
Source: https://github.com/fcalell/dotfiles/tree/main/dot_claude/skills/tanstack-query
Command: npx skills add https://github.com/fcalell/dotfiles --skill tanstack-query-fcalell

SYSTEM DOCUMENTATION & REQUIREMENTS

What problem does it solve?

TanStack Query simplifies client-side server state management by handling data fetching, caching, background updates, and synchronization with the server.

Core Features & Use Cases

  • Centralized data fetching with useQuery and useMutation patterns
  • Cache management, invalidation, and optimistic updates
  • Dependent and infinite queries for complex UIs
  • Use cases include building responsive dashboards, lists with filters, and real-time updates

Quick Start

Install TanStack Query in a React project and configure it to manage server state across components for a cohesive, fast UI.

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 data in React?

To fetch and cache server data in React, you can use centralized data fetching patterns like useQuery to automatically manage background updates and keep your UI in sync with the server.

What is the best way to handle optimistic updates for React mutations?

The best way to handle optimistic updates for React mutations is using the useMutation pattern, which allows you to coordinate cache invalidation and synchronously update the UI before the server responds.

Can I use TanStack Query for dependent and infinite queries in complex UIs?

Yes, you can use TanStack Query for dependent and infinite queries. It supports these patterns natively, making it suitable for building responsive dashboards and lists with filters in complex UIs.

Why do I need server-state management instead of just fetching data?

You need server-state management because simply fetching data does not handle background updates, caching, or synchronization. A dedicated solution keeps your UI cohesive and fast by automatically managing server state across components.

How do I invalidate the cache after a mutation in a React app?

To invalidate the cache after a mutation in a React app, use the coordinated mutation features provided by useMutation to trigger cache invalidation, ensuring your data fetching stays reliably in sync.