plugins/tanstack-start-expert/skills/start-server-routes/SKILL.md
Use when building raw HTTP API endpoints in TanStack Start — the server property on createFileRoute, method handlers (GET/POST/PUT/DELETE), the handler context (request, params, context), createHandlers for per-handler middleware, file-route conventions, dynamic/splat params, request body parsing, and Response helpers. Do NOT use for: internal type-safe RPC from your own app (use start-server-functions), reusable middleware chains (use start-middleware), or UI route rendering.
npx skillsauth add fusengine/agents start-server-routesInstall this skill globally with one command. Works with Claude Code, Cursor, and Windsurf.
3 of 9 scanners reported clean
Some scanners were skipped, did not run, or reported a non-clean status. Review each row below.
Server routes are raw HTTP endpoints defined alongside app routes in
src/routes/. They use the server property on createFileRoute (imported
from @tanstack/react-router) and return standard Response objects. This skill
targets @tanstack/react-start v1.166.2.
Before implementing, verify current APIs against Context7
(/websites/tanstack_start_framework_react) + Exa, then explore the target
codebase. After changes, run fuse-ai-pilot:sniper.
routes/users.ts, routes/users/index.ts,
and routes/users.index.ts all resolve to /users and error if duplicated.await body methods. request.json(), .text(), .formData()
return Promises — un-awaited, you get a Promise, not the data.Response (or Promise<Response>). Use
Response.json(...) for JSON, or new Response(body, { status, headers }).component
alongside server.| Feature | Description |
|---------|-------------|
| Definition | server: { handlers: { GET, POST, ... } } on createFileRoute |
| Handler context | { request, params, context, pathname, next } |
| Middleware | server.middleware (all handlers) or createHandlers (per handler) |
| Params | Dynamic ($id) and splat ($) from the file name |
src/routes/
├── api/
│ ├── hello.ts # /api/hello
│ ├── users/$id.ts # /api/users/$id (dynamic param)
│ └── file/$.ts # /api/file/$ (splat param)
└── webhooks/stripe.ts # /webhooks/stripe (external POST)
→ See rest-endpoint.md
| Topic | Reference | Load when | |-------|-----------|-----------| | Defining routes | defining.md | Handlers, params, body, responses, middleware | | Routes vs functions | vs-server-functions.md | Deciding between the two mechanisms |
| Template | When to Use | |----------|-------------| | rest-endpoint.md | Full REST resource with params + middleware |
// src/routes/api/hello.ts
import { createFileRoute } from '@tanstack/react-router'
export const Route = createFileRoute('/api/hello')({
server: {
handlers: {
GET: async ({ request }) => new Response('Hello, World!'),
},
},
})
// src/routes/api/users/$id.ts
export const Route = createFileRoute('/api/users/$id')({
server: {
handlers: {
GET: async ({ params }) => {
const user = await findUser(params.id)
if (!user) return new Response('Not found', { status: 404 })
return Response.json(user)
},
},
},
})
→ See defining.md for middleware and body parsing
Response.json() for JSON (sets Content-Type automatically)await every request body methodauthMiddleware on routes handling private dataResponsetesting
Copy self-audit and ban-lists — filler verbs/hype adjectives, slop placeholder names, fake-precise numbers, Title Case headlines, humor in error copy ('Oops!'), em-dash crutch, one copy register per page.
development
Logged-in web apps — dashboards, auth flows, settings, onboarding, data tables, command palettes, modals, toasts. Register `product`: density and glance-speed over marketing polish, no hero/CTA-tricks, every data surface covers empty/loading/error explicitly, tables and dataviz follow preattentive-processing rules.
development
Marketing sites, landing pages, campaign pages — register `brand` (design IS the product). Structure comes from the register's POV + a macrostructure pick, never from copying an inspiration site's section flow. Hero discipline, deviated section order, asymmetric grids, and a silhouette lookalike-test gate before ship.
development
Token-strategy core — OKLCH color rules, neutral tinting, accent-commitment levels, type scale, 8pt spacing grid, touch targets, and the canonical output format of design-system.md (the file the harness gates on). This is routing step 1 of design-method/SKILL.md — read it before design-web/design-webapp/design-ios/design-android, before picking or auditing a single color/type/spacing value.