deckardger avatar

Tanstack Integration Best Practices

If you're wiring up TanStack Query with Router and Start, this gives you the architectural patterns to avoid the common pitfalls. It covers the critical setup pieces like passing QueryClient through router context and the SSR integration with dehydrate/hydrate, then moves into data flow patterns like using loaders with ensureQueryData and coordinating mutations with invalidation. The caching guidance is solid: let Query handle the cache, don't fight it with router-level caching. What's useful here is the priority system. The three critical setup rules and the SSR integration rule are genuinely foundational. Get those wrong and you'll spend hours debugging hydration mismatches and stale data issues.

skills.sh installs
3K
GitHub stars
230
last updated
Aug 21, 2026

Install

$ npx -y skills add deckardger/tanstack-agent-skills --skill tanstack-integration-best-practices --agent claude-code

Installs into .claude/skills of the current project.

Files

TanStack Integration Best Practices

Guidelines for integrating TanStack Query, Router, and Start together effectively. These patterns ensure optimal data flow, caching coordination, and type safety across the stack.

When to Apply

  • Setting up a new TanStack Start project
  • Integrating TanStack Query with TanStack Router
  • Configuring SSR with query hydration
  • Coordinating caching between router and query
  • Setting up type-safe data fetching patterns

Rule Categories by Priority

PriorityCategoryRulesImpact
CRITICALSetup3 rulesFoundational configuration
CRITICALSSR Integration1 ruleRouter + Query SSR setup
HIGHData Flow4 rulesCorrect data fetching patterns
MEDIUMCaching3 rulesPerformance optimization
MEDIUMSSR2 rulesAdditional SSR patterns

Quick Reference

Setup (Prefix: setup-)

  • setup-query-client-context — Pass QueryClient through router context
  • setup-provider-wrapping — Correctly wrap with QueryClientProvider
  • setup-stale-time-coordination — Coordinate staleTime between router and query

Data Flow (Prefix: flow-)

Sponsors

Details

Repository
github.com/deckardger/tanstack-agent-skills
Categories
Frontend Development, AI & Agent Building

More from deckardger/tanstack-agent-skills

All 4
1nexu-io avatarmarketing-psychologynexu-io/open-designApply psychological principles and behavioral science to copy and design. Useful for tightening hooks, framing, and pricing presentation.3Kskills.sh installs
2nexu-io avatartheme-factorynexu-io/open-designApply professional font and color themes to artifacts including slides, docs, reports, and HTML landing pages. Ships 10 pre-set themes.3Kskills.sh installs
3nexu-io avatarfigma-implement-designnexu-io/open-designTranslate Figma designs into production-ready code with 1:1 visual fidelity. Useful for handing off Figma frames straight to a frontend agent.2.9Kskills.sh installs
4wshobson avatarpptx-reference-deck-analysiswshobson/agentsUse when analyzing a reference PPTX for read-only structure, theme, typography, layout rhythm, diagnostics, derived template catalogs, or safe OOXML package ins2.9Kskills.sh installs
5openai avatarfigma-generate-libraryopenai/skillsBuild or update a professional-grade design system in Figma from a codebase. Use when the user wants to create variables/tokens, build component libraries, set 2.9Kskills.sh installs
6sanity-io avatarportable-text-conversionsanity-io/agent-toolkitConvert HTML and Markdown content into Portable Text blocks for Sanity. Use when migrating content from legacy CMSs, importing HTML or Markdown into Sanity, bui2.9Kskills.sh installs