agentsclimarketplace

Nextjs tanstack query

Skill fusengine/agents/plugins/nextjs-expert/skills/nextjs-tanstack-query

TanStack Query v5 integration with Next.js 16. Server-side prefetching, hydration, useQuery, useMutation, cache management. Use when: implementing client-side data fetching with caching, server-side prefetching with hydration, or optimistic mutations in Next.js.From its SKILL.md

Install
npx -y skills add fusengine/agents --skill nextjs-tanstack-query

Assembled from the repository path, not quoted from the project. Check it against their README if it does not work.

One thing to look at

  • 22 stars22 stars. Stars are a popularity signal and not a quality one, but at this level it is likely that nobody has read this closely except its author, and you would be relying on your own review.

SKILL.md

2.9 KB, 591 tokens by cl100k_base, as published. Nobody here has run it

TanStack Query for Next.js

TanStack Query v5 provides powerful server state management with Next.js 16 integration.

Agent Workflow (MANDATORY)

Before ANY implementation, use TeamCreate to spawn 3 agents:

  1. fuse-ai-pilot:explore-codebase - Analyze existing data fetching patterns
  2. fuse-ai-pilot:research-expert - Verify latest TanStack Query v5 docs
  3. mcp__context7__query-docs - Check TanStack Query + Next.js patterns

After implementation, run fuse-ai-pilot:sniper for validation.


Overview

When to Use

  • Client-side data fetching with caching and revalidation
  • Server-side prefetching with hydration to client
  • Optimistic updates for mutations
  • Infinite scrolling and pagination
  • Real-time data synchronization

Why TanStack Query

FeatureBenefit
Server prefetchingData ready on first render, no loading flash
Automatic cachingDeduplication, stale-while-revalidate
MutationsOptimistic updates, rollback on error
DevToolsVisual cache inspection
TypeScript-firstFull type inference

Critical Rules

  1. One QueryClient per request - Create in Server Component, share via context
  2. Prefetch in Server Components - Use prefetchQuery for SSR data
  3. HydrationBoundary required - Wrap client tree to transfer server cache
  4. Query keys must be serializable - Arrays of strings/numbers only
  5. staleTime on prefetched queries - Prevent immediate refetch on mount
  6. Never use queryClient in Client Components directly - Use hooks

Installation

bun add @tanstack/react-query @tanstack/react-query-devtools

Best Practices

  1. Prefetch on server - Avoid loading states for critical data
  2. Set staleTime - Prevent unnecessary refetches after hydration
  3. Collocate query keys - Define keys near their usage
  4. Invalidate on mutation - Use invalidateQueries after writes
  5. Error boundaries - Use throwOnError for critical queries
  6. DevTools in dev only - Wrap in process.env.NODE_ENV check

Reference Guide

NeedReference
useQuery, useMutationquery-patterns.md
Server prefetchinghydration.md
QueryClient setuphydration.md
Cache invalidationquery-patterns.md

What ships with it: 2 files

5.2 KB alongside SKILL.md

references/

Keep looking

Skills are one crate of 325,949. Ordering is by how many stacks a row turns up in, so the top of any crate is what has actually been picked rather than what has the most stars.