start-server-routes

Build raw HTTP endpoints in TanStack Start using the server property on createFileRoute.

1|Updated Jul 29, 2026
One-click install
npx skills add https://github.com/fusengine/kimi-code --skill start-server-routes-fusengine
Or copy as Structured Prompt for Agent▼
Please help me install this Agent Skill.
Skill: start-server-routes
Source: https://github.com/fusengine/kimi-code/tree/main/plugins/tanstack-start-expert/skills/start-server-routes
Command: npx skills add https://github.com/fusengine/kimi-code --skill start-server-routes-fusengine

SYSTEM DOCUMENTATION & REQUIREMENTS

💡 This Skill requires @tanstack/react-router, @tanstack/react-start, and includes references (resource) components.

What problem does it solve? When you need an endpoint callable from outside your TanStack Start app — webhooks, public REST APIs, OAuth callbacks, or cross-origin clients — internal server functions are not enough. This Skill guides the implementation of server routes: raw HTTP handlers defined alongside app routes that return standard Response objects. ## Core Features & Use Cases - HTTP Handlers with Full Context: Define GET, POST, PUT, DELETE handlers receiving request, params, context, pathname, and next, with dynamic ($id) and splat ($) params from the file name. - Middleware Control: Apply route-wide middleware via server.middleware or per-handler middleware via createHandlers, with correct execution ordering. - Decision Guidance: Clear rules for choosing a server route versus a server function, plus collision rules (one handler file per route path) and body-parsing requirements. - Use Case: You need a Stripe webhook receiver at /webhooks/stripe. This Skill provides the template: a POST handler that reads the raw body with await request.text(), verifies the signature, and returns the correct Response status. ## Quick Start Ask the agent to create a server route at src/routes/api/users/$id.ts with GET and DELETE handlers that read params.id and return Response.json results.

Frequently Asked Questions about start-server-routes

High-intent search queries and answers about installing and using this skill.

FAQPage Schema
How do I create an API route in TanStack Start?▼

Add a server property to createFileRoute in a file under src/routes/, mapping HTTP methods to handlers. Each handler receives request, params, context, pathname, and next, and must return a Response or Promise<Response>.

TanStack Start server route vs server function: which should I use?▼

Use a server route when the endpoint is callable from outside your app, such as webhooks, public REST, or cross-origin clients. Use a server function (createServerFn) for internal type-safe RPC called only from your own loaders and components.

How do I read dynamic route params in a TanStack Start server route?▼

Name the file with a $ prefix, like routes/api/users/$id.ts, then read params.id inside the handler. Splat routes use $.ts and expose the remaining path as params._splat.

Why is my request body undefined in a TanStack Start handler?▼

request.json(), request.text(), and request.formData() return Promises, so you must await them. Writing const body = request.json() without await gives you a Promise instead of the parsed data.

Can I add middleware to only one HTTP method in a server route?▼

Yes, define handlers as a function receiving createHandlers and attach a middleware array to specific methods. Route-level server.middleware runs first and applies to all handlers, then per-handler middleware runs.

Why do I get an error about duplicate route paths in TanStack Start?▼

Only one handler file may resolve to a given route path. routes/users.ts, routes/users/index.ts, and routes/users.index.ts all map to /users and conflict, so keep a single handler file per path.