2
GitHub Stars
1
Bundled Files
2 months ago
Catalog Refreshed
4 months ago
First Indexed
Readme & install
Copy the install command, review bundled files from the catalogue, and read any extended description pulled from the listing source.
Installation
Preview and clipboard use veilstrat where the catalogue uses aiagentskills.
npx veilstrat add skill fusengine/agents --skill react-tanstack-router- SKILL.md11.9 KB
Overview
This skill provides a practical guide and patterns for implementing TanStack Router in React applications. It focuses on 100% type-safe, file-based routing with loaders, search-params validation, and first-class TanStack Query integration. Use it to standardize routing, data loading, and URL-driven state across a SOLID-structured React SPA.
How this skill works
It prescribes file-based route files that export typed Route instances, each able to declare loaders, beforeLoad guards, and validated search schemas. Loaders integrate with a shared QueryClient so pages preload and cache data via TanStack Query. The skill also requires an agent workflow for discovery and validation before and after changes.
When to use it
- Building a React SPA (Vite, Webpack, Rspack) — not for Next.js App Router
- You need full TypeScript inference for route params and search params
- Pages require data preloading and caching with TanStack Query
- You want consistent, file-based routing structure across a codebase
- Implementing protected routes, nested layouts, or URL-driven filters
Best practices
- Always use file-based routing to get auto-generated type safety
- Validate search params with Zod (zodValidator) for predictable parsing and defaults
- Prefer Route loaders (and ensureQueryData) over useEffect to fetch data before render
- Register router module types (declare module '@tanstack/react-router') for global type inference
- Integrate TanStack Query for caching, optimistic updates, and consistent queryOptions
Example use cases
- Posts listing page with Zod-validated filter and pagination search params and a loader that ensures query data
- Protected admin dashboard that redirects unauthenticated users in beforeLoad and uses nested layouts
- Post detail route using createFileRoute('/posts/$postId') with a loader that uses queryClient.ensureQueryData
- Feature module scaffolded with SOLID folders: interfaces, queries, components, and exported route files
- Prefetching link intent to preload heavy pages and improve perceived performance
FAQ
Before implementation spawn three agents: explore-codebase, research-expert, and query-docs to analyze routes, verify docs, and check file-based patterns. After implementation run a validation agent (sniper) to confirm correctness.
How do I validate search params safely?
Define a Zod schema and pass it to validateSearch via zodValidator on the Route. This yields typed search values with defaults and runtime validation.