new-api-route

Creates HTTP API endpoints using TanStack Start file-based routing on Cloudflare Workers.

1|Updated Jul 8, 2026
One-click install
npx skills add https://github.com/fayazara/bangalore.fyi --skill new-api-route-fayazara
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: new-api-route
Source: https://github.com/fayazara/bangalore.fyi/tree/main/.agents/skills/new-api-route
Command: npx skills add https://github.com/fayazara/bangalore.fyi --skill new-api-route-fayazara

SYSTEM DOCUMENTATION & REQUIREMENTS

What problem does it solve? TanStack Start's API route patterns changed rapidly and most AI training data contains outdated APIs like createServerFileRoute, causing generated endpoints to fail. This Skill provides the exact current patterns for adding REST endpoints in this TanStack Start + Cloudflare Workers codebase. ## Core Features & Use Cases - File-based route creation: Maps file paths like src/routes/api/items.$id.ts to URLs with dynamic $ segments and correct createFileRoute strings. - Handler structure with validation: Implements GET/POST/PUT/PATCH/DELETE handlers returning Web Response objects, with zod or drizzle-zod input validation. - Binding access: Shows how to use D1, R2, and other Cloudflare bindings via import { env } from "cloudflare:workers" or the Drizzle client. - Use Case: When asked to "add a POST endpoint at /api/orders that validates input and writes to D1", this Skill produces a working route file on the first attempt. ## Quick Start Ask the agent to add a new API endpoint, for example: create a GET and POST route at /api/products that validates the request body and stores items in the D1 database.

Frequently Asked Questions about new-api-route

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 under src/routes/api and export a Route using createFileRoute with a server.handlers object containing GET, POST, or other HTTP method functions. Each handler receives { request, params } and returns a Web Response object.

How do I add dynamic route parameters in TanStack Start API routes?

Use a $ prefix in the file name, such as src/routes/api/items.$id.ts, which maps to /api/items/:id. The parameter is available in the handler as params.id, and the createFileRoute string must be "/api/items/$id".

How do I access Cloudflare D1 or R2 bindings in a TanStack Start route?

Import env directly from the cloudflare:workers module at the top of the route file, then call env.DB.prepare(...) or env.STORAGE.get(...) inside handlers. Do not use process.env or pass env as a function argument.

How do I validate request bodies in a TanStack Start API route?

Parse the JSON body inside a try/catch, then validate it with a zod schema using safeParse, returning a 400 Response on failure. For data matching a database table, use drizzle-zod's createInsertSchema to derive the schema from the Drizzle table definition.

Why does createServerFileRoute not work in TanStack Start?

createServerFileRoute is an outdated API from earlier TanStack Start versions. Current versions use createFileRoute with a server.handlers configuration object, and pure API routes should not export a component.