LogoAwesome Skills
  • Search
  • Category
  • Tag
  • Blog
LogoAwesome Skills
LogoAwesome Skills

Discover Open-Source Agent Skills for AI Coding Assistants

Product

  • Search
  • Category
  • Tag
  • Blog

Resources

  • Claude Skill Docs
  • Antigravity Skills Docs

Tools

  • Claude Code
  • OpenCode
  • Cursor
  • Codex
  • Antigravity

Company

  • Privacy Policy
  • Terms of Service
  • Sitemap

©2026 Awesome Skills. All rights reserved.

Privacy PolicyTerms
Back to Skills

tanstack-integration-best-practices

Best practices for integrating TanStack Query with TanStack Router and TanStack Start. Patterns for full-stack data flow, SSR, and caching coordination.

187stars17forksUpdated 6/25/2026
Web Development#tanstack#best-practices#data-fetching#react#ssr#caching

Security Assessment

Safe(90/100)

Detected risks:

Sensitive File Access([rules/ssr-dehydrate-hydrate.md] .env)
Security Score90/100

About tanstack-integration-best-practices

A set of best practices for integrating TanStack Query with TanStack Router and TanStack Start so that data flow, caching coordination, and type safety work consistently across a full-stack application. It is intended to be applied when setting up a new TanStack Start project, wiring TanStack Query into TanStack Router, configuring server-side rendering with query hydration, coordinating caching between router and query, or establishing type-safe data-fetching patterns.

The guidance is organized as prioritized rule categories. Setup rules, marked CRITICAL, cover passing the QueryClient through router context, wrapping correctly with QueryClientProvider, and coordinating staleTime between router and query. SSR integration, also CRITICAL, centers on using setupRouterSsrQueryIntegration for automatic dehydrate and hydrate. HIGH-priority data-flow rules describe using loaders with ensureQueryData, useSuspenseQuery in components, coordinating mutations with query invalidation, and using server functions as query functions. MEDIUM-priority caching rules recommend letting TanStack Query be the single source of truth, coordinating preloading between router and query, and unifying invalidation patterns, while additional SSR rules cover creating a QueryClient per request and handling streaming queries.

Each rule lives in its own file under a rules directory and follows a consistent structure: an explanation of why the pattern matters, a bad example showing the anti-pattern to avoid, a good example showing the recommended implementation, and context on when to apply or skip the rule. A quick-reference list groups the rules by prefix, setup, flow, cache, and ssr, so the relevant guidance can be located by concern, with the SKILL.md acting as an index that points to the detailed rule files.

FAQ

When should I apply these best practices?

Apply them when setting up a new TanStack Start project, integrating TanStack Query with TanStack Router, configuring SSR with query hydration, coordinating caching, or setting up type-safe data fetching.

Which rules are marked most critical?

The Setup category, covering QueryClient context, provider wrapping, and staleTime coordination, and the SSR Integration rule for setupRouterSsrQueryIntegration are marked CRITICAL.

What is the recommended data-flow pattern?

Use loaders with ensureQueryData, useSuspenseQuery in components, coordinate mutations with query invalidation, and use server functions as query functions.

How should caching responsibility be divided?

Let TanStack Query be the single source of truth for caching, coordinate preloading between router and query, and use unified invalidation patterns.

How is each rule documented?

Each rule file under the rules directory includes an explanation, a bad example, a good recommended example, and context on when to apply or skip it.

All Files

5 files
rules/flow-loader-query-pattern.md4.7 KB
View
SKILL.md2.5 KB
View
rules/setup-query-client-context.md4.3 KB
View
rules/cache-single-source.md4.6 KB
View
rules/ssr-dehydrate-hydrate.md5.4 KB
View

Install tanstack-integration-best-practices

Download and extract the skill files to your .claude/skills/ directory.

Quick Setup:

  1. Copy the skill folder to .claude/skills/
  2. Claude will automatically detect and use the skill

Repository

deckardger/tanstack-agent-skills

Related Skills

short-form-video

14

multi-asset-morning-briefing

7,907

content-strategy

2,901

doherty-threshold

2,901