tanstack-react-query-patterns

Organize TanStack Query code with hierarchical keys and queryOptions factories.

5|Updated Feb 12, 2026
One-click install
npx skills add https://github.com/agusmdev/fullstack-ai-template --skill tanstack-react-query-patterns
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: tanstack-react-query-patterns
Source: https://github.com/agusmdev/fullstack-ai-template/tree/main/.claude/skills/tanstack-react-query-patterns
Command: npx skills add https://github.com/agusmdev/fullstack-ai-template --skill tanstack-react-query-patterns

SYSTEM DOCUMENTATION & REQUIREMENTS

What problem does it solve?

Standardizes and accelerates the implementation of TanStack Query patterns by providing a structured approach to query keys, options factories, and prefetching strategies across SSR and SPA contexts.

Core Features & Use Cases

  • Hierarchical query keys and type-safe keys for consistent cache management.
  • Query options factory to centralize fetch logic and defaults.
  • Prefetching and dependent/parallel queries to improve UX.
  • Pattern examples for infinite, placeholder, select transformations, and optimistic updates.
  • Guidance for integrating with TanStack Start (SSR) and TanStack Router (SPA).

Quick Start

Create a minimal project example applying query keys, the queryOptions factory, and a sample detail/list data fetch to validate patterns.

Frequently Asked Questions about tanstack-react-query-patterns

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

FAQPage Schema
How do I structure TanStack Query keys for consistent cache management?

Structure TanStack Query keys using a hierarchical query-key system to ensure consistent cache management. This approach organizes keys systematically, enabling reliable cache invalidation and type-safe data fetching across your application.

What is a queryOptions factory in TanStack Query?

A queryOptions factory in TanStack Query centralizes fetch logic and defaults into reusable definitions. It enforces type-safety parameters, allowing you to standardize data fetching patterns across SSR and SPA contexts.

How do I implement prefetching strategies with TanStack Router?

Implement prefetching strategies with TanStack Router by applying structured patterns for dependent and parallel queries. This improves UX by loading data before navigation, utilizing options compatible with SPA client-only and SSR full-stack setups.

Does this approach work with TanStack Start for SSR data fetching?

Yes, this approach works with TanStack Start for SSR full-stack data fetching. The patterns integrate with TanStack Start and TanStack Router, structuring keys, prefetching, and data transformations for server-side rendering.

How do I handle optimistic updates and data transformations in React Query?

Handle optimistic updates and data transformations in React Query by applying centralized pattern examples. These include select transformations for shaping data and optimistic update logic, ensuring type-safe cached state modifications.

What is the best way to organize TanStack Query code in TypeScript?

The best way to organize TanStack Query code in TypeScript is using a queryOptions factory with a hierarchical query-key system. This centralizes fetch logic and ensures type-safe, reusable patterns across your project.