Installation
Install the React Start package:Vite Plugin Setup
Configure the TanStack Start Vite plugin in yourvite.config.ts:
Router Setup
Create your router instance insrc/router.tsx:
Server Functions
TanStack React Start provides server functions for executing code on the server with full type safety.Creating Server Functions
UsecreateServerFn to define server-side logic:
Using Server Functions in Components
Call server functions using theuseServerFn hook:
useServerFn hook automatically handles:
- Type-safe function calls
- Redirect responses from server functions
- Integration with TanStack Router navigation
Middleware
Add middleware to server functions for shared logic like authentication, logging, or data validation.Creating Middleware
Using Middleware in Server Functions
Input Validation
Validate server function inputs with validators like Zod, Valibot, or ArkType:HTTP Methods
Server functions support both GET and POST methods:Client and Server Contexts
Share context between client and server:Package Exports
TanStack React Start provides several package exports:@tanstack/react-start- Main client exports@tanstack/react-start/server- Server-only utilities@tanstack/react-start/client- Client-only utilities@tanstack/react-start/plugin/vite- Vite plugin@tanstack/react-start/server-rpc- Server RPC utilities@tanstack/react-start/client-rpc- Client RPC utilities@tanstack/react-start/ssr-rpc- SSR RPC utilities
React-Specific Features
React Server Components (RSC)
TanStack React Start supports React Server Components for optimized server rendering:Streaming
Support for React Suspense and streaming SSR:TypeScript Configuration
Ensure yourtsconfig.json includes:
Peer Dependencies
TanStack React Start requires:- React >= 18.0.0 or >= 19.0.0
- React DOM >= 18.0.0 or >= 19.0.0
- Vite >= 7.0.0
Next Steps
Server Functions
Learn more about creating and using server functions
Routing
Explore TanStack Router features
Examples
Browse React Start examples
API Reference
View the complete API documentation