data-fetching

Implement TanStack Query data fetching patterns in React applications.

Updated Jan 18, 2026
One-click install
npx skills add https://github.com/mrgizmo212/deepagents-openrouter --skill data-fetching-mrgizmo212
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: data-fetching
Source: https://github.com/mrgizmo212/deepagents-openrouter/tree/main/agent/skills/data-fetching
Command: npx skills add https://github.com/mrgizmo212/deepagents-openrouter --skill data-fetching-mrgizmo212

SYSTEM DOCUMENTATION & REQUIREMENTS

💡 This Skill includes references (resource) components.

What problem does it solve?

This Skill addresses the complexities of fetching, caching, and managing asynchronous data in React applications, ensuring a smooth user experience with loading and error states.

Core Features & Use Cases

  • Data Fetching & Caching: Utilizes TanStack Query for efficient data retrieval and caching.
  • Loading & Error States: Provides clear visual feedback during data loading and handles errors gracefully.
  • Mutations & Optimistic Updates: Enables data modification with immediate UI feedback.
  • Infinite Scroll & Pagination: Supports fetching large datasets in manageable chunks.
  • Dependent Queries: Manages data dependencies between different queries.
  • Prefetching: Improves perceived performance by fetching data proactively.
  • Server Components: Integrates with Next.js Server Components for data fetching at the framework level.

Quick Start

Use the data-fetching skill to implement a user profile component that fetches user data by ID and displays loading or error states.

Frequently Asked Questions about data-fetching

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

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

Data fetching in React applications is managed using TanStack Query for efficient data retrieval and caching. This approach handles asynchronous data complexities, ensuring smooth user experiences with proper loading and error states.

What is the best way to handle loading and error states with TanStack Query?

Handling loading and error states with TanStack Query involves implementing comprehensive state management to provide clear visual feedback during data loading. It addresses asynchronous data complexities by handling errors gracefully throughout the data fetching lifecycle.

How do I implement optimistic updates for mutations in React?

Optimistic updates for mutations in React are implemented using TanStack Query to enable data modification with immediate UI feedback. This pattern allows applications to update the interface instantly before the server confirms the mutation.

Can I use TanStack Query for infinite scroll and pagination in Next.js?

TanStack Query supports infinite scroll and pagination in Next.js by fetching large datasets in manageable chunks. It manages data dependencies between queries and improves perceived performance through proactive data prefetching.

Does TanStack Query work with Next.js Server Components for data retrieval?

TanStack Query integrates with Next.js Server Components for data retrieval at the framework level. This integration allows developers to fetch data efficiently on the server before sending it to the client.