KS
Killer-Skills

React-Query — how to use React-Query how to use React-Query, React-Query vs Redux, React-Query setup guide, what is React-Query, React-Query alternative, React-Query install, asynchronous data management, React-Query caching, React-Query CRUD operations

v1.0.0
GitHub

About this Skill

Ideal for Frontend Agents requiring efficient asynchronous data management and caching using @tanstack/react-query v5. React-Query is a library for managing asynchronous data in React applications, providing features like automatic cache synchronization and feedback visualizations.

Features

Implement asynchronous data fetching using @tanstack/react-query v5
Manage loading and error states for a better user experience
Automatically synchronize cache after mutations
Perform CRUD operations with feedback visualizations
Invalidate queries after mutations for data consistency
Optimize data pagination and listing with React-Query

# Core Topics

endriwmsi endriwmsi
[0]
[0]
Updated: 3/2/2026

Quality Score

Top 5%
39
Excellent
Based on code quality & docs
Installation
SYS Universal Install (Auto-Detect)
Cursor IDE Windsurf IDE VS Code IDE
> npx killer-skills add endriwmsi/hub-ln/React-Query

Agent Capability Analysis

The React-Query MCP Server by endriwmsi is an open-source Categories.community integration for Claude and other AI agents, enabling seamless task automation and capability expansion. Optimized for how to use React-Query, React-Query vs Redux, React-Query setup guide.

Ideal Agent Persona

Ideal for Frontend Agents requiring efficient asynchronous data management and caching using @tanstack/react-query v5.

Core Value

Empowers agents to simplify data fetching, caching, and synchronization with automatic cache invalidation after mutations, utilizing @tanstack/react-query v5 for seamless asynchronous data management, and managing loading and error states effectively.

Capabilities Granted for React-Query MCP Server

Fetching paginated data from servers
Implementing CRUD operations with visual feedback
Synchronizing cache automatically after data mutations
Managing loading and error states for improved user experience

! Prerequisites & Limits

  • Requires @tanstack/react-query v5 library
  • Limited to React-based applications
Project
SKILL.md
4.0 KB
.cursorrules
1.2 KB
package.json
240 B
Ready
UTF-8

# Tags

[No tags]
SKILL.md
Readonly

React Query (TanStack Query)

Esta skill orienta a implementação de gerenciamento de dados assíncronos usando @tanstack/react-query v5, seguindo os padrões estabelecidos neste projeto.

Quando usar esta skill

  • Buscar dados do servidor - Listagens, detalhes, dados paginados
  • Criar, atualizar ou deletar recursos - Operações CRUD com feedback visual
  • Sincronizar cache automaticamente - Invalidar queries após mutations
  • Gerenciar loading/error states - Estados de carregamento e erro de forma declarativa

Como usar

1. Estrutura de Arquivos

Os hooks de React Query devem seguir a estrutura feature-based:

src/features/{feature-name}/
├── actions/         # Server actions (Next.js)
    ├──action.ts
├── schemas/         # Tipos e validações Zod
    ├──schema.ts
├── hooks/
    ├── use-{entities}.ts        # Query para listar (ex: use-services.ts)
    ├── use-create-{entity}.ts   # Mutation para criar
    ├── use-update-{entity}.ts   # Mutation para atualizar
    └── use-delete-{entity}.ts   # Mutation para deletar

2. Convenções de Nomenclatura

TipoPadrãoExemplo
Query (listar)use{Entities}useServices, useUsers
Query (detalhe)use{Entity}useService, useUser
Mutation (criar)useCreate{Entity}useCreateService
Mutation (atualizar)useUpdate{Entity}useUpdateService
Mutation (deletar)useDelete{Entity}useDeleteService

3. Query Keys

Use arrays estruturados para query keys:

typescript
1// ✅ Bom - permite invalidação granular 2queryKey: ["services"]; // Lista todos 3queryKey: ["services", { onlyActive: true }]; // Lista com filtro 4queryKey: ["services", id]; // Detalhe por ID 5 6// ❌ Evitar - dificulta invalidação 7queryKey: ["all-services"]; 8queryKey: [`service-${id}`];

4. Padrão de useQuery (Buscar Dados)

typescript
1"use client"; 2 3import { useQuery } from "@tanstack/react-query"; 4import { getEntities } from "../actions"; 5 6export function useEntities(filter?: boolean) { 7 return useQuery({ 8 queryKey: ["entities", { filter }], 9 queryFn: () => getEntities(filter), 10 }); 11}

5. Padrão de useMutation (Modificar Dados)

typescript
1"use client"; 2 3import { useMutation, useQueryClient } from "@tanstack/react-query"; 4import { toast } from "sonner"; 5import { createEntity } from "../actions"; 6import type { CreateEntityInput } from "../schemas"; 7 8export function useCreateEntity() { 9 const queryClient = useQueryClient(); 10 11 return useMutation({ 12 mutationFn: (data: CreateEntityInput) => createEntity(data), 13 onSuccess: (result) => { 14 if (result.success) { 15 toast.success("Criado com sucesso!"); 16 queryClient.invalidateQueries({ queryKey: ["entities"] }); 17 } else { 18 toast.error("Erro ao criar"); 19 } 20 }, 21 onError: () => { 22 toast.error("Erro ao criar"); 23 }, 24 }); 25}

6. Uso em Componentes

tsx
1"use client"; 2 3import { useEntities } from "../hooks/use-entities"; 4import { useCreateEntity } from "../hooks/use-create-entity"; 5 6export function EntitiesTable() { 7 const { data, isLoading, error } = useEntities(); 8 const createMutation = useCreateEntity(); 9 10 if (isLoading) return <Loading />; 11 if (error) return <Error message={error.message} />; 12 13 const handleCreate = (data: CreateEntityInput) => { 14 createMutation.mutate(data); 15 }; 16 17 return <Table data={data} />; 18}

Regras importantes

[!IMPORTANT] Todos os hooks de React Query devem incluir "use client" no topo do arquivo.

[!TIP] Sempre invalide queries relacionadas após uma mutation para manter o cache sincronizado.

[!WARNING] Não use queryClient.setQueryData para modificar o cache diretamente, prefira invalidateQueries para garantir dados frescos.

Referências

Related Skills

Looking for an alternative to React-Query or building a Categories.community AI Agent? Explore these related open-source MCP Servers.

View All

widget-generator

Logo of f
f

widget-generator is an open-source AI agent skill for creating widget plugins that are injected into prompt feeds on prompts.chat. It supports two rendering modes: standard prompt widgets using default PromptCard styling and custom render widgets built as full React components.

149.6k
0
Design

chat-sdk

Logo of lobehub
lobehub

chat-sdk is a unified TypeScript SDK for building chat bots across multiple platforms, providing a single interface for deploying bot logic.

73.0k
0
Communication

zustand

Logo of lobehub
lobehub

The ultimate space for work and life — to find, build, and collaborate with agent teammates that grow with you. We are taking agent harness to the next level — enabling multi-agent collaboration, effortless agent team design, and introducing agents as the unit of work interaction.

72.8k
0
Communication

data-fetching

Logo of lobehub
lobehub

The ultimate space for work and life — to find, build, and collaborate with agent teammates that grow with you. We are taking agent harness to the next level — enabling multi-agent collaboration, effortless agent team design, and introducing agents as the unit of work interaction.

72.8k
0
Communication