Skip to content

secondsky/claude-skills / plugins/tanstack-start/skills/tanstack-start

tanstack-start

Verified

TanStack Start (RC) full-stack React with server functions, SSR, Cloudflare Workers. Use for Next.js migration, edge rendering, or encountering hydration, auth, data pattern errors.

references/routing-and-data-loading.md

View on GitHub
# Routing & Data Loading (TanStack Start / Router)

## Route Tree and File-Based Routing
- Files under `app/routes/**` become routes; `createFileRoute()` infers params and builds the route tree automatically. Use code-based routes (`createRootRoute`, `createRoute`, `rootRoute.addChildren`) when you need dynamic composition.  
- Route matching order: index → static segments → dynamic (`$id`) → splat (`$`), so place catch-alls last to avoid accidental matches.

## Path + Search Params (Type Safe)
- Path params are typed from the file name (`/posts/$postId.tsx` → `{ postId: string }`).
- Add `validateSearch` with zod to coerce/validate search params:
```ts
export const Route = createFileRoute('/posts/')({
  validateSearch: z.object({ page: z.coerce.number().default(1) }),
})
```
- For custom serialization (dates, arrays), provide `parseSearch`/`stringifySearch` to keep types stable across navigations.

## Loaders (data fetching)
- `loader` runs once per location change; return plain data or throw `redirect()` / `notFound()` to control flow.
- Keep loaders pure and side-effect free; mutations should live in actions or server functions.
- Access router context (`context.queryClient`, user/session, env) via the loader signature.

## Deferred + External Data
- When upstream latency is high, return partial data and stream the rest using deferred responses; pair with suspense boundaries in components.
- External data loaders can live outside route files; pass them into `loader` to keep route modules lean.

## Mutations
- Use route `action` (or Start server functions) for writes; invalidate affected routes with `router.invalidate()` or query invalidation when using TanStack Query.
```ts
export const Route = createFileRoute('/posts/new')({
  action: async ({ data, context }) => {
    await context.api.createPost(data)
    await context.queryClient.invalidateQueries({ queryKey: ['posts'] })
    return redirect({ to: '/posts' })
  },
})
```

## Static Route Data
- Add `staticData` for values that never change (e.g., breadcrumb labels); Start can inline this in prerendered builds to avoid runtime fetches.

## Error & Not-Found Handling
- Throw `notFound()` inside loaders/actions for 404s; render per-route `notFoundComponent` or an error boundary to show friendly UX.
- Prefer structured errors over generic throws so error boundaries can branch on status/type.
slack-gif-creatoranthropics/skillsKnowledge and utilities for creating animated GIFs optimized for Slack. Provides constraints, validation tools, and animation concepts. Use when users request animated GIFs for Slack like "make me a GIF of X doing Y for Slack."Stars: 197kUpdated Claude CodeCodexVerifiedInstall
ponytailDietrichGebert/ponytailLazy senior dev mode for any coding task: the smallest change that fully solves it, and a reply a busy human understands in one read.Stars: 194kUpdated Claude CodeCodexVerifiedInstall
ponytail-debtDietrichGebert/ponytailHarvest every shortcut: comment into one debt ledger, so deferrals get tracked instead of forgotten. One-shot report.Stars: 194kUpdated Claude CodeCodexVerifiedInstall
ponytail-debtDietrichGebert/ponytailList every `shortcut:` comment (and older `ponytail:` ones) as a debt ledger. One-shot report, changes nothing. Use for "ponytail debt", "what did ponytail defer", "list the shortcuts", /ponytail-debt.Stars: 194kUpdated Claude CodeCodexVerifiedInstall