TanStack Mutations

Implement TanStack Query mutations with cache synchronization and optimistic updates in React apps.

7|2|Updated Jan 9, 2026
One-click install
npx skills add https://github.com/salmanrrana/brain-dump --skill tanstack-mutations
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: TanStack Mutations
Source: https://github.com/salmanrrana/brain-dump/tree/main/.opencode/skill/tanstack-mutations
Command: npx skills add https://github.com/salmanrrana/brain-dump --skill tanstack-mutations

SYSTEM DOCUMENTATION & REQUIREMENTS

💡 This Skill includes references (resource) components.

What problem does it solve?

This skill provides structured guidance for implementing TanStack Query mutations, cache synchronization, and optimistic updates to build responsive UIs.

Core Features & Use Cases

  • Use useMutation for server mutations with consistent cache handling and error management.
  • Implement optimistic updates and robust rollback strategies to maintain UI responsiveness.
  • Apply centralized invalidation patterns and concurrent mutation handling across multiple queries.

Quick Start

Explain TanStack Mutation patterns and show a practical toggle example using optimistic updates.

Frequently Asked Questions about TanStack Mutations

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

FAQPage Schema
How do I implement optimistic updates with TanStack Query mutations?

Implement optimistic updates by using the onMutate context in useMutation to manually update the cache via queryClient before the server responds, ensuring responsive UI and providing rollback strategies if the mutation fails.

What is the best way to handle cache invalidation after a React Query mutation?

Handle cache invalidation by applying centralized invalidation patterns within the onSettled callback of useMutation, ensuring multiple affected queries are synchronized and conflict-free after server mutations complete.

How do useMutation onMutate and onSettled patterns work for server mutations?

The onMutate pattern executes optimistic cache updates before server requests, while onSettled handles final cache synchronization and error handling after the mutation resolves, ensuring consistent state management.

Can I manage concurrent TanStack mutations across multiple queries?

Yes, you can manage concurrent TanStack mutations across multiple queries by applying centralized invalidation strategies and robust error handling to maintain UI responsiveness and prevent cache conflicts.