tanstack-start
TanStack Start, Router, Query, and Server Functions patterns and best practices for this project.
SKILL.md.claude/skills/tanstack-start/SKILL.md
GitHubTanStack Start Patterns
Server Functions
- Define with
createServerFnfrom@tanstack/react-start - Use
.validator()for input validation (e.g. with zod) - Use
.handler()for the implementation - Server functions run on the server only — safe for DB access and secrets
Router
- File-based routing in
src/routes/ - Use
createFileRoutefor route definitions - Use
loaderfor server-side data fetching (runs on server) - Use
beforeLoadfor auth guards and redirects - Route context flows from
__root.tsxto child routes
Query
- Use
queryOptionsto define reusable query configs - Use
useSuspenseQueryin components for data fetching - Invalidate queries after mutations with
queryClient.invalidateQueries() - TanStack Query handles caching, deduplication, and background refetching
Key Conventions
- Path alias:
@/→apps/web/src/ - Route files:
src/routes/<path>.tsx - Layouts:
src/routes/_<layout>.tsx(pathless layout routes) - API routes:
src/routes/api/<name>.ts