mcpField
T
tanstack-frontend

tanstack-frontend

github.com/blogic-czDevelopment368 installsUpdated 1d ago
Repository

About tanstack-frontend

tanstack-frontend is a skill that provides project-specific patterns for TanStack Router, TRPC, TanStack Query, and forms. It helps frontend developers follow route loading, suspense, typing, cache invalidation, and shared form conventions.

Key features

  1. 01Loader-driven route data patterns
  2. 02Guidance for query prefetch and Suspense
  3. 03TRPC v11 query and mutation conventions
  4. 04RouterInputs and RouterOutputs typing
  5. 05Shared project form patterns
  6. 06Frontend import and component conventions

Use cases

  1. 01Implementing a route with critical data preloaded
  2. 02Choosing prefetch behavior for route queries
  3. 03Adding typed TRPC queries or mutations
  4. 04Building forms with shared project components

Install

Copy the command and run it in a terminal.

$npx skills add https://github.com/blogic-cz/blogic-marketplace --skill tanstack-frontend

After installing, type/tanstack-frontendin Claude Code to confirm it loaded.

Bundled files

References and scripts installed along with SKILL.md.

references/
form-patterns.md
prefetch-patterns.md
router-loader-examples.md
trpc-v11-query-pattern.md
type-inference.md

Details

From the project README

TanStack Frontend Patterns

Overview

Implement TanStack Router routes with project-standard TRPC integration, loader strategy, typed inference, and form handling. Follow this document for decision rules, then use references/ for full examples.

Core Patterns

1) Define routes with loader-driven data strategy
  • Define each route with createFileRoute(...) and a loader that preloads critical data.
  • Read params/search from route APIs (Route.useParams(), Route.useSearch()) in components.
  • Keep examples in references/router-loader-examples.md.
2) Choose loader prefetch strategy intentionally
  • Use await prefetchQuery(...) for data required in first paint.
  • Use await Promise.all([...]) for multiple critical queries.
  • Use void prefetchQuery(...) only for secondary data.
  • Use fetchQuery(...) when loader logic needs returned data.
  • Apply the void rule together with the Suspense rule below.

See full decision trees and performance tradeoffs in references/prefetch-patterns.md.

3) Enforce Suspense boundaries for void-prefetched data
  • Wrap every component that consumes void prefetchQuery(...) data via useSuspenseQuery(...) in <Suspense>.
  • Treat missing boundaries as correctness bugs (hydration risk), not optional optimization.
  • Cross-check any void decision against this requirement before finalizing the route.

See examples and the loader-pattern decision table in references/prefetch-patterns.md.

4) Apply TRPC v11 TanStack Query pattern

Use one rule block consistently:

  • Use TanStack Query hooks (useQuery, useSuspenseQuery, useMutation) with TRPC factory methods.
  • Use .queryOptions(...) for queries/prefetch and .mutationOptions(...) for mutations.
  • Use .queryKey(...) for cache invalidation.
  • Do not call .useQuery() or .useMutation() on TRPC procedures.

See concise do/don't examples in references/trpc-v11-query-pattern.md.

5) Prefer RouterInputs/RouterOutputs for inference
  • Prefer RouterInputs/RouterOutputs for input/response typing across route components and helpers.
  • Allow explicit local types when they represent UI-only view models, external library contracts, or deliberate narrowing/aggregation that does not mirror server payloads.
  • Avoid duplicating raw TRPC response shapes as hand-written app types.

See practical inference patterns in references/type-inference.md.

6) Use the project form wrapper (not raw TanStack Form)
  • Treat "TanStack Form" in this template as useAppForm + @/shared/forms/* field components.
  • Compose forms with shared form components and pass form/field explicitly.
  • Avoid raw TanStack Form hooks in feature code unless updating the shared form infrastructure itself.

See complete form patterns in references/form-patterns.md.

7) Follow frontend conventions
  • Prefer type Props = ... naming for component props.
  • Use absolute imports (@/...).
  • Import shared cross-package types from @project/common.
  • Invalidate TRPC cache through queryKey(...) helpers.

Resources

references/
  • router-loader-examples.md - Complete route definition examples
  • prefetch-patterns.md - Performance optimization and prefetch strategies
  • trpc-v11-query-pattern.md - Compact TRPC v11 query/mutation/invalidation rules
  • form-patterns.md - Form handling with validation examples
  • type-inference.md - TRPC type inference patterns and examples

Comments

Markdown supported