start-core-server-routes

Implements server-side API endpoints using createFileRoute server handlers in TanStack Start.

Updated Dec 21, 2025
One-click install
npx skills add https://github.com/Angael/veles --skill start-core-server-routes-angael
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: start-core-server-routes
Source: https://github.com/Angael/veles/tree/main/.agents/skills/start-core-server-routes
Command: npx skills add https://github.com/Angael/veles --skill start-core-server-routes-angael

SYSTEM DOCUMENTATION & REQUIREMENTS

What problem does it solve? Building HTTP API endpoints in a TanStack Start application requires knowing how to attach raw request handlers to file-based routes, parse request bodies, and return proper responses. This Skill provides the patterns for defining server routes with the server property on createFileRoute. ## Core Features & Use Cases - HTTP Method Handlers: Define GET, POST, PUT, and DELETE handlers that receive the raw Request object, route params, and middleware context. - Middleware Support: Apply middleware to all handlers at the route level or per-handler using createHandlers for fine-grained control. - File-Based API Routing: Map files like routes/users/$id.ts and splat routes like routes/file/$.ts to URL paths, with rules to avoid duplicate route path conflicts. - Use Case: You need a /api/users endpoint that accepts JSON POST bodies and returns JSON responses with proper status codes, plus an auth-protected POST handler alongside a public GET handler. ## Quick Start Create a server route at src/routes/api/hello.ts with a GET handler that returns a JSON response using the server property on createFileRoute.

Frequently Asked Questions about start-core-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?

Create a file in src/routes and use the server property on createFileRoute with a handlers object. Each HTTP method like GET or POST receives a context with request, params, and context, and must return a Response object.

How do I parse a JSON request body in a TanStack Start server route?

Call await request.json() inside your handler to parse the JSON body. You can also use request.text() or request.formData() for other body types, and you must await these methods since they return promises.

Can I add middleware to specific handlers in TanStack Start server routes?

Yes, use the createHandlers function to attach middleware to individual handlers. Route-level middleware defined in the server property runs first for all handlers, then handler-specific middleware runs after it.

Why do I get a duplicate route path error in TanStack Router?

Each route path can only have one handler file, so routes/users.ts, routes/users.index.ts, and routes/users/index.ts all conflict because they resolve to /users. Pick a single file for each route path.

When should I use server routes versus server functions in TanStack Start?

Server routes handle raw HTTP requests and are suited for REST APIs, webhooks, and non-HTML responses. Server functions are better for RPC-style calls from your own UI components where you want typed function calls instead of manual fetch logic.