start-core/server-functions

Create type-safe server functions with createServerFn for TanStack Start.

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

SYSTEM DOCUMENTATION & REQUIREMENTS

What problem does it solve?

This skill provides type-safe, server-only functions for TanStack Start, enabling you to run server-side logic behind createServerFn without leaking implementation to the client and keeping loaders/isomorphic code clean.

Core Features & Use Cases

  • Create server functions with createServerFn for GET/POST methods, with input validation and server-only logic.
  • Client integrations via useServerFn, server context utilities (getRequest, getRequestHeader, setResponseHeader, setResponseStatus).
  • Error handling & streaming with redirect, notFound, and FormData support; suitable for loaders, components, and server routes.

Quick Start

Create a server function with createServerFn, wire it into a loader or component, and call it to perform server-side tasks.

Frequently Asked Questions about start-core/server-functions

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

FAQPage Schema
How do I create type-safe server functions in TanStack Start?

Type-safe server functions in TanStack Start are created using createServerFn to encapsulate server-only logic behind GET or POST RPCs. This ensures server-side code stays clean and does not leak implementation details to the client.

Can I use server functions with loaders and components in TanStack Start?

Yes, server functions integrate directly with loaders and components in TanStack Start. You can wire createServerFn into a loader or component and call it to securely perform server-side tasks while maintaining full type safety.

How does TanStack Start handle server context and request headers?

TanStack Start handles server context by exposing utilities like getRequest, getRequestHeader, setResponseHeader, and setResponseStatus. These allow server functions to directly read request data and manipulate response headers or status codes.

Does TanStack Start support streaming and FormData in server functions?

Yes, TanStack Start supports streaming and FormData within server functions. This enables efficient handling of file uploads and progressive data delivery alongside standard input validation and server-only logic execution.

What is the best way to handle errors and redirects in TanStack Start server functions?

The best way to handle errors and redirects in TanStack Start server functions is using built-in utilities like redirect and notFound. These ensure proper routing control and error management within your server-side RPC logic.

Why should I use server functions instead of standard API routes in TanStack Start?

Server functions provide type-safe RPCs that keep loaders and isomorphic code clean, preventing server-only logic from leaking to the client. Unlike standard API routes, they offer seamless input validation and direct component integration.