nextjs-tanstack-query
БесплатноБез исполняемых скриптовНе проверенUse when implementing client-side data fetching, server prefetching with hydration, or optimistic mutations in Next.js 16 with TanStack Query.
от Fusengine★ 36 звёзд на GitHubОб этом скилле
Covers serializable query keys, staleTime tuning on prefetched queries to avoid immediate refetch, cache invalidation with invalidateQueries after writes, infinite scrolling/pagination, and DevTools setup gated to development only. Does not cover the Server Component boundary itself (nextjs-server-components) or core Next.js caching primitives like use cache (nextjs-16) — this skill is specifically about TanStack Query's client-side cache layer.
TanStack Query for Next.js
TanStack Query v5 provides powerful server state management with Next.js 16 integration.
Agent Workflow (MANDATORY)
Before ANY implementation, spawn 3 agents in parallel, one Agent call each with a name:
- fuse-ai-pilot:explore-codebase - Analyze existing data fetching patterns
- fuse-ai-pilot:research-expert - Verify latest TanStack Query v5 docs
- 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
| Feature | Benefit |
|---|---|
| Server prefetching | Data ready on first render, no loading flash |
| Automatic caching | Deduplication, stale-while-revalidate |
| Mutations | Optimistic updates, rollback on error |
| DevTools | Visual cache inspection |
| TypeScript-first | Full type inference |
Critical Rules
- One QueryClient per request - Create in Server Component, share via context
- Prefetch in Server Components - Use
prefetchQueryfor SSR data - HydrationBoundary required - Wrap client tree to transfer server cache
- Query keys must be serializable - Arrays of strings/numbers only
staleTimeon prefetched queries - Prevent immediate refetch on mount- Never use
queryClientin Client Components directly - Use hooks
Installation
bun add @tanstack/react-query @tanstack/react-query-devtools
Best Practices
- Prefetch on server - Avoid loading states for critical data
- Set
staleTime- Prevent unnecessary refetches after hydration - Collocate query keys - Define keys near their usage
- Invalidate on mutation - Use
invalidateQueriesafter writes - Error boundaries - Use
throwOnErrorfor critical queries - DevTools in dev only - Wrap in
process.env.NODE_ENVcheck
Reference Guide
| Need | Reference |
|---|---|
| useQuery, useMutation | query-patterns.md |
| Server prefetching | hydration.md |
| QueryClient setup | hydration.md |
| Cache invalidation | query-patterns.md |
Установить nextjs-tanstack-query в Claude Code и Claude Desktop
Зарегайся, чтобы установить скилл
Создай бесплатный аккаунт, чтобы открыть команду установки и сохранить скилл в библиотеку.
- Открой команду установки в одну строку
- Сохраняй скиллы в синхронизируемую библиотеку
- Уведомления, когда скиллы обновляются
Разрешённые инструменты
Инструменты, которые скиллу разрешено вызывать.
Без ограничений — скилл может использовать любой инструмент.
Вложенные файлы
FAQ
Что делает скилл nextjs-tanstack-query?
Use when implementing client-side data fetching, server prefetching with hydration, or optimistic mutations in Next.js 16 with TanStack Query.
Как установить скилл nextjs-tanstack-query?
Скопируй папку скилла в ~/.claude/skills (вкладка Claude Code выше делает это одной командой), либо поставь как плагин.
Скилл nextjs-tanstack-query запускает скрипты?
Нет, скилл состоит только из инструкций (SKILL.md), без исполняемых скриптов.
Похожие скиллы
skill-creator
Create new skills, modify and improve existing skills, and measure skill performance. Use when users want to create a skill from scratch, edit, or optimize an…
от Anthropicdiscernment-nudge
After you give a substantive answer or draft that the user may act on — advice or recommendations, drafted artifacts such as goals, plans, pitches, proposals…
от Anthropicdata-consolidate
Joins the plant's scheduled exports and connector data into one working dataset — ERP items (NetSuite or Infor M3), sales orders, production work orders…
от Anthropicinspection-to-capa
Runs the quality chain end to end: writes the nonconformance against the requirement it violates, searches history at the moment of writing to say whether…
от Anthropic