start-core/server-routes

Define server-side API endpoints with createFileRoute in src/routes.

14.9k|1.8k|Updated Jan 14, 2019
One-click install
npx skills add https://github.com/TanStack/router --skill start-core-server-routes
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: start-core/server-routes
Source: https://github.com/TanStack/router/tree/main/packages/start-client-core/skills/start-core/server-routes
Command: npx skills add https://github.com/TanStack/router --skill start-core-server-routes

SYSTEM DOCUMENTATION & REQUIREMENTS

What problem does it solve?

Organizing server-side API endpoints alongside UI routes by using the server property on createFileRoute.

Core Features & Use Cases

  • Server routes are API endpoints defined alongside app routes in the src/routes directory. They use the server property on createFileRoute to handle raw HTTP requests and expose GET, POST, PUT, DELETE handlers.
  • Supports per-handler middleware, request parsing, and response helpers; provides a consistent routing model with parameter and context handling.
  • Useful for building API backends that live next to UI routes, enabling cohesive data fetching and SSR patterns.

Quick Start

Create a file under src/routes, export a Route with createFileRoute('/path') and define server handlers (GET/POST, etc.) to implement the API.

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 define server API routes alongside UI routes in TanStack Start?

Server API routes in TanStack Start are defined by using the server property on createFileRoute within the src/routes directory. This allows you to expose GET, POST, PUT, and DELETE HTTP handlers directly next to your app's UI components.

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

Yes, per-route middleware is supported on server routes in TanStack Start. You can apply middleware to specific handlers to intercept requests, parse payloads, and manage context before the primary GET or POST logic executes.

What is the best way to structure backend API endpoints in a TanStack Start application?

The best way to structure backend API endpoints is co-locating them with UI routes using createFileRoute. This cohesive routing model parameterizes requests and handles responses seamlessly, enabling robust SSR and data fetching patterns.

Does TanStack Start support raw HTTP request handling for methods like PUT and DELETE?

TanStack Start supports raw HTTP request handling for methods like PUT and DELETE through the server property on createFileRoute. It provides request parsing and response helpers to manage these raw interactions effectively.

Why organize server-side API endpoints next to app routes instead of a separate API folder?

Organizing server-side API endpoints next to app routes creates a cohesive routing model that simplifies parameter and context handling. This co-location enables unified data fetching and SSR patterns without splitting backend logic into a separate folder.