Skip to content
Skills Library
Programming · Building & coding

yapyak-tanstack-start

/yapyak-tanstack-start

TanStack Start: route files, route-component naming, loaders, route-scoped hooks, `.server.ts`, server functions. Use when editing route files or server-only code.

Repository
yapyak ↗
Licence
MIT
Last repository change
15.10.2026

Assessment and security

100/ 100Class: good
Format25 / 25
Frontmatter with name and description, valid name, description up to 1,024 characters, name matching the folder.
Discoverability25 / 25
Description explains when to use the skill, has a reasonable length and uses third person.
Content35 / 35
At least 150 words and at most 500 lines, headings, step lists, examples or code.
Hygiene15 / 15
No placeholders such as TODO, no Windows paths, with a licence.
Riskno signals detected in the scan
Files in this package
1
Scripts
0
HTML comments
0
URLs in SKILL.md
0
Deprecation

No signals detected. Repository changed on 15.10.2026, without references to retired models or APIs.

Licence

MIT, open: use and modify while retaining author attribution.

What it does and when to use it

TanStack Start: route files, route-component naming, loaders, route-scoped hooks, `.server.ts`, server functions. Use when editing route files or server-only code.

Original author description

TanStack Start: route files, route-component naming, loaders, route-scoped hooks, `.server.ts`, server functions. Use when editing route files or server-only code.

How it works

SKILL.md has no level-two headings · 105 lines, 747 words

SKILL.md preview
---
name: yapyak-tanstack-start
description: "TanStack Start: route files, route-component naming, loaders, route-scoped hooks, `.server.ts`, server functions. Use when editing route files or server-only code."
metadata:
  internal: true
---

### Route files

- Route files (`src/routes/`) contain the Route definition (loader + `Component` function).
- `Component` is the page — it composes domain components from `src/components/`.
- No "Page" wrapper components — the route `Component` owns the page layout.
- Route config callbacks use shorthand method syntax: `async loader({ context }) {`, not `loader: async ({ context }) => {`.

### Route-scoped hooks

In route files, **always use route-scoped hooks** — never their top-level equivalents from `@tanstack/react-router`. The route-scoped variants are typed to the specific route.

```ts
Route.useParams()
Route.useSearch()
Route.useLoaderData()
Route.useNavigate()
Route.useRouteContext()
```

### Route component naming

Route component functions match TanStack config keys: `component: Component`, `errorComponent: ErrorComponent`, `pendingComponent: PendingComponent`, `notFoundComponent: NotFoundComponent`.

**Route config component values must be named function references defined in the same file.** Never inline arrows, never import a component from elsewhere into the config.

```ts
// ✓ Right — named function in same file
export const Route = createFileRoute('/foo')({
  component: Component,
});

function Component() {
  return <div />;
}

// ✗ Wrong — inline arrow
component: () => <div />,

// ✗ Wrong — imported from another file
import { FooPage } from '#components/foo-page';
component: FooPage,
```

### Route config option order

```
1. validateSearch, search
2. loaderDeps, beforeLoad, loader
3. shouldRevalidateLoader, gcTime
4. onEnter, onStay, onLeave, onCatch
5. head, meta, scripts, headers
6. pendingMs, pendingMinMs, wrapInSuspense
7. component, pendingComponent, errorComponent, notFoundComponent, shellComponent
```

### Loaders

| Rule | Detail |
|---|---|
| Loaders return an object | Always use explicit `return`, never implicit arrow shorthand. |
| Project fields, never derive | The loader may **select** fields off the fetched value — property access, destructuring, renaming, a literal/spread built from those. It may NOT **derive** — no call that computes over the loaded data (`getAnchors(blocks)`, `.filter(…)`, `getPageTitle(page)`), no value-producing operator on it. Derivation happens at the point of use in the component — see [[yapyak-react]] § Pass whole objects. |
| `useLoaderData()` only in `Component` | Never call it in domain components. |
| Loader data is always defined | No `\| undefined` guards needed. |

**Projection vs derivation — mechanical test.** Set aside the fetch call and its argument prep (`params._splat ?? ''` is input, not output). The returned expression is a legal **projection** iff it holds no call expressions and no value-deriving operators over the loaded data — only property access, destructuring, renaming, literals, and spread. A single computing call (`getAnchors(blocks)`, `.filter(…)`) makes it **derivation** → move it to the component.

```ts
// ✓ projection — select the fields this route needs
async loader({ params }) {
  const entry = await loadEntry('guide', params._splat ?? '');
  return { blocks: entry.blocks, page: entry.page };
}

// ✗ derivation — getAnchors computes a new value
async loader({ params }) {
  const entry = await loadEntry('guide', params._splat ?? '');
  return { anchors: getAnchors(entry.blocks), page: entry.page };
}
```

### Search params

- `stripSearchParams(DEFAULTS)` on each route so default values stay out of the URL.
- The `search` prop on links controls what survives navigation — set it explicitly.

### Router invalidation

`router.invalidate()` is always called with `{ sync: true }`: `await router.invalidate({ sync: true })`.

### Server functions — `@tanstack/react-start`

- Data fetching uses `createServerFn()` (GET is the default; never specify `{ method: 'GET' }`).
- Server functions return **plain data** (discriminated unions, primitives, arrays) — never class instances. Serialization (seroval) only handles JSON-compatible shapes.

### Server-only helpers — `.server.ts` suffix

`.server.ts` marks a file as server-only — it never bundles to the client. A client component that imports from a `.server.ts` fails the build loudly.

- **Route-specific server helpers** live next to the route: `routes/post.$.server.ts` is the companion to `routes/post.$.tsx`.
- **Cross-route shared server helpers** live in `lib/*.server.ts`.
- **Function names inside `.server.ts`** are plain action verbs — `loadArticle`, `loadManifest`, `parseSource`. No prefix/suffix to mark them server-only; the file extension already does.
- **Types shared between client and server live in a non-`.server.ts` file.** Functions in `lib/x.server.ts`, types in `lib/x.ts`. Client components import types via `import type` from the type file. Domain/content types live in the shared `.ts` type file and are imported. A UI `?:`-optional Props type is declared in the component file (per [[yapyak-react]]) and derived from the domain type; never re-declared in the shared file.
- **A type stays in a `.server.ts`** only when it references a server-only runtime value via `typeof` (e.g. `ReturnType<typeof loadArticle>`); the client then imports it via `import type` only — erased at build, no runtime leak. Otherwise it moves to the `.ts` type file.

Versions

The database has no other skills named yapyak-tanstack-start.

Database snapshot: 13.11.2026 · package version 25a4a43f37b1 (SHA-256 digest of the entire package)

Downloads in the last 30 days: 3 · ranking

Report a problem with this skill: harmful content, incorrect descriptions or an author’s removal request.

Similar skills

  • 95tanstack-start
    Build JSON-defined TanStack Start applications with @json-render/tanstack-start. Use for Start route specs, splat routing, SSR loaders, head metadata, layouts, and client navigation. Do not use for generic TanStack Router apps that do not use json-render.
  • 100yapyak
    yapyak, an i18n compiler with a small runtime: t() with the source string as the key, ICU plurals and selects, rich text, format.* for numbers, dates and lists, locale switching and persistence, yapyak.config.ts, translators, the yapyak CLI, and YAPnnnn diagnostics. Use when…
  • 100tanstack
    Type-safe React with TanStack Query (fetching, caching, mutations), Router (file-based routing, search params, loaders), and Start (SSR, server functions). Use for react-query, server state, typed search params, route loaders, or SSR.
  • 100yapyak
    yapyak, an i18n compiler with a small runtime: t() with the source string as the key, ICU plurals and selects, rich text, format.* for numbers, dates and lists, locale switching and persistence, yapyak.config.ts, translators, the yapyak CLI, and YAPnnnn diagnostics. Use when…
  • 100tanstack-start-architecture
    Use when creating, moving, or naming files in a full-stack TanStack Start app (file-based routes, server functions) that also uses TanStack Query, Form, Table, DB, and Devtools, organized by technical layer. Covers routes, server/ (functions, middleware, services, db),…
  • 100start-auth
    Use when adding auth to a TanStack Start app — route protection, server-function authorization, sessions, CSRF. Do NOT use for generic route guards.

Feedback and reports

Your message goes to Bartosz Sokoliński. An email address is needed only for a reply. See the privacy policy.