Full-Stack Architecture
TanStack Start is a full-stack framework built on top of TanStack Router that enables you to build modern web applications with seamless client-server integration. It combines the power of server-side rendering (SSR), streaming, and server functions into a unified development experience.Overview
TanStack Start provides a complete full-stack solution that includes:- Unified Router: Built on TanStack Router with file-based or code-based routing
- Server Functions: Type-safe RPC-like functions that run on the server
- SSR & Streaming: Server-side rendering with progressive hydration
- API Routes: File-based API endpoints with full HTTP method support
- Middleware System: Request and function-level middleware for cross-cutting concerns
- Built-in Bundling: Powered by Vite with optimized code splitting
Architecture Components
Client-Server Split
TanStack Start automatically splits your application into client and server bundles:packages/start-server-core/src/createStartHandler.ts:352
Package Structure
TanStack Start is organized into specialized packages:@tanstack/start-client-core: Client-side runtime for server function calls@tanstack/start-server-core: Server-side request handling and SSR@tanstack/react-start: React-specific bindings and components@tanstack/start-plugin-core: Build-time transformations and routing
Request Flow
Here’s how a typical request flows through TanStack Start:1. Initial Page Load (SSR)
2. Client-Side Navigation
Start Handler
ThecreateStartHandler function is the entry point for your server:
- Normalizes incoming requests
- Executes request middleware
- Routes to server functions or page routes
- Handles SSR and streaming responses
- Manages asset URLs and manifests
packages/start-server-core/src/createStartHandler.ts:353-650
Type Safety
TanStack Start provides end-to-end type safety:Environment Detection
TanStack Start automatically handles code that runs in different environments:Development vs Production
TanStack Start optimizes differently for each environment:Development
- Hot module replacement (HMR) for instant updates
- Source maps for debugging
- Detailed error messages
- Fresh manifest on each request for route-specific styles
Production
- Optimized bundles with code splitting
- Cached manifests for performance
- Minified assets
- CDN-ready asset URLs
packages/start-server-core/src/createStartHandler.ts:165-173
Middleware System
TanStack Start supports two types of middleware:Request Middleware
Runs once per HTTP request:Function Middleware
Runs for each server function call:packages/start-client-core/src/createServerFn.ts:196-336
Asset Management
TanStack Start automatically manages your application assets:- JavaScript module preloads
- CSS stylesheet links
- Client entry scripts
packages/start-server-core/src/createStartHandler.ts:59-112
Next Steps
- Learn about Server Functions for client-server communication
- Explore SSR capabilities for server-side rendering
- Understand Streaming for progressive rendering
- Review Deployment strategies for production