One-click install
npx skills add https://github.com/captjay98/livestockai --skill tanstack-query-captjay98
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: TanStack Query
Source: https://github.com/captjay98/livestockai/tree/main/.kiro/skills/tanstack-query
Command: npx skills add https://github.com/captjay98/livestockai --skill tanstack-query-captjay98

SYSTEM DOCUMENTATION & REQUIREMENTS

What problem does it solve?

TanStack Query centralizes client-side data state in LivestockAI, reducing boilerplate for mutations and cache management.

Core Features & Use Cases

  • Route loaders handle data fetching while TanStack Query handles mutations and cache invalidation to keep UI synchronized across farms.
  • Mutations with optimistic updates and robust error handling ensure responsive UI during create/update/delete operations.
  • Cache invalidation and query refetch strategies maintain data consistency after mutations across multiple components.

Quick Start

Integrate TanStack Query into your React components and begin mutating data with useMutation, then invalidate queries to refresh UI.

Frequently Asked Questions about TanStack Query

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

FAQPage Schema
How do I manage React mutations and cache invalidation with TanStack Query?

Apply optimistic updates in React by immediately updating the UI state within a TanStack Query mutation before the server responds, then rolling back changes automatically if the server request fails, ensuring a responsive frontend experience.

What is the best way to combine route loaders with TanStack Query for initial data fetching?

Combine route loaders with TanStack Query by using the route loader to fetch initial data on navigation, while delegating subsequent mutations and cache invalidation to React Query to keep the UI synchronized without redundant network requests.

How do optimistic updates work with TanStack Query mutations?

Optimistic updates in TanStack Query mutations immediately reflect expected changes in the UI before server confirmation, providing a responsive user experience during create and update operations while automatically rolling back if error handling detects a failure.

Why does my React UI lose sync after mutations when using TanStack Query?

Your React UI loses sync after mutations if cache invalidation strategies are not enforced, meaning related queries are not refetched or invalidated properly, leaving stale data across components that depend on the mutated server state.

Do I need server functions to handle mutations with TanStack Query?

You need server functions to handle mutations with TanStack Query because the mutation hook triggers the server-side operation, and the client relies on the server response to enforce error handling and execute consistent cache invalidation.