agentsclimarketplace

Start server routes

Skill fusengine/agents/plugins/tanstack-start-expert/skills/start-server-routes

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.From its SKILL.md

Install
npx -y skills add fusengine/agents --skill start-server-routes

Assembled from the repository path, not quoted from the project. Check it against their README if it does not work.

One thing to look at

  • 22 stars22 stars. Stars are a popularity signal and not a quality one, but at this level it is likely that nobody has read this closely except its author, and you would be relying on your own review.

SKILL.md

4.4 KB, 944 tokens by cl100k_base, as published. Nobody here has run it

TanStack Start Server Routes

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.

Agent Workflow (MANDATORY)

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.

Critical Rules (read first)

  1. Server route vs server function: an endpoint callable from outside your app (webhooks, public REST, cross-origin) → server route. Internal type-safe RPC → server function. See vs-server-functions.md.
  2. One handler file per route path. routes/users.ts, routes/users/index.ts, and routes/users.index.ts all resolve to /users and error if duplicated.
  3. Always await body methods. request.json(), .text(), .formData() return Promises — un-awaited, you get a Promise, not the data.
  4. Handlers must return Response (or Promise<Response>). Use Response.json(...) for JSON, or new Response(body, { status, headers }).
  5. The same file can be both a UI route and an API route — add component alongside server.

Overview

FeatureDescription
Definitionserver: { handlers: { GET, POST, ... } } on createFileRoute
Handler context{ request, params, context, pathname, next }
Middlewareserver.middleware (all handlers) or createHandlers (per handler)
ParamsDynamic ($id) and splat ($) from the file name

Architecture

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

Reference Guide

Concepts

TopicReferenceLoad when
Defining routesdefining.mdHandlers, params, body, responses, middleware
Routes vs functionsvs-server-functions.mdDeciding between the two mechanisms

Templates

TemplateWhen to Use
rest-endpoint.mdFull REST resource with params + middleware

Quick Reference

Basic GET

// 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!'),
    },
  },
})

JSON with dynamic param and status

// 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

Best Practices

DO

  • Use server routes for webhooks, public REST, and cross-origin endpoints
  • Return Response.json() for JSON (sets Content-Type automatically)
  • await every request body method
  • Add authMiddleware on routes handling private data

DON'T

  • Duplicate a route path across multiple files
  • Reach for a server route when you want internal type-safe RPC
  • Forget to return a Response

What ships with it: 4 files

9.2 KB alongside SKILL.md

Keep looking

Skills are one crate of 325,949. Ordering is by how many stacks a row turns up in, so the top of any crate is what has actually been picked rather than what has the most stars.