start-server-functions

Implements type-safe RPC server functions with createServerFn in TanStack Start applications.

1|Updated Jul 29, 2026
One-click install
npx skills add https://github.com/fusengine/kimi-code --skill start-server-functions-fusengine
Or copy as Structured Prompt for Agent▼
Please help me install this Agent Skill.
Skill: start-server-functions
Source: https://github.com/fusengine/kimi-code/tree/main/plugins/tanstack-start-expert/skills/start-server-functions
Command: npx skills add https://github.com/fusengine/kimi-code --skill start-server-functions-fusengine

SYSTEM DOCUMENTATION & REQUIREMENTS

💡 This Skill requires @tanstack/react-start, @tanstack/react-router, zod, and includes references (resource) components.

What problem does it solve? Building server-side logic in TanStack Start requires correctly wiring createServerFn validators, handlers, and serialization rules, and mistakes like relying on route guards for auth or putting database queries in isomorphic loaders create real security holes. This Skill provides the rules, references, and templates to implement server functions correctly. ## Core Features & Use Cases - Server Function Creation: Guides createServerFn usage with GET/POST methods, Zod or plain-function validators, handlers, and strict serialization rules. - Security Enforcement: Covers auth inside handlers or middleware, CSRF protection via createCsrfMiddleware, and correct Cache-Control headers for authenticated responses. - Ready-Made Templates: Includes a full CRUD module and a FormData submission template with Zod validation and progressive enhancement. - Use Case: When adding a mutation that creates a post and redirects to a dashboard, use this Skill to build the server function with auth middleware, Zod validation, and the required useServerFn hook in the component. ## Quick Start Ask the agent to create a TanStack Start server function that validates input with Zod, enforces auth in the handler, and is called from a route loader.

Frequently Asked Questions about start-server-functions

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

FAQPage Schema
How do I create a server function in TanStack Start?▼

Use createServerFn from @tanstack/react-start with a method option, then chain .validator() for input validation and .handler() for the server-only logic. Call it with a single { data } argument from loaders, components, or other server functions.

When is useServerFn required in TanStack Start?▼

useServerFn is mandatory when the server function throws redirect() or notFound(), because the hook wires the throw into the router for navigation. For plain-data functions it is optional; a direct call or useMutation works fine.

Does a route beforeLoad guard protect TanStack Start server functions?▼

No, a beforeLoad redirect only protects the route UI. A server function is an independent HTTP endpoint reachable directly, so auth must be enforced inside the handler or via middleware on every function touching private data.

Can I use FormData with createServerFn validators?▼

Yes, FormData is allowed as input only for POST server functions. Validate its shape manually in the validator, for example by checking instanceof FormData and coercing fields into an object validated with Zod.

Why does my TanStack Start redirect never navigate from a button click?▼

The redirect throw is swallowed when the function is called directly in an onClick handler. Wrap the function with useServerFn in the component so the router handles the redirect or notFound throw.

When should I not use createServerFn in TanStack Start?▼

Do not use server functions for public or cross-origin HTTP endpoints, which belong in server routes, or for composable middleware chains, which belong in dedicated middleware. Also avoid Next.js or Remix patterns like "use server" or loader/action.