Build Architecture
TanStack Start creates two separate build environments:- Client Environment: Browser-side code with optimized assets
- Server Environment: Node.js code for SSR and server functions
environments configuration.
Output Directories
By default, TanStack Start outputs builds to:Client Build Options
Configure the client environment build:Client Asset Base Path
Control where client assets are served from:Server Build Options
Configure the server environment build:Static NODE_ENV Replacement
Replaceprocess.env.NODE_ENV at build time for dead code elimination:
process.env.NODE_ENV is replaced with the actual value during build, allowing bundlers to eliminate dead code:
Dependency Optimization
Configure how dependencies are bundled:Code Splitting
Control code splitting behavior:Build Targets
Specify target environments:Production Optimizations
Minification
Tree Shaking
Vite automatically tree-shakes unused code. Ensure your dependencies support ES modules:Compression
Use a Vite plugin to compress assets:Custom Build Process
The build process can be customized using Vite’sbuilder API:
Environment-Specific Configuration
Use different settings per environment:Build Analysis
Analyze your bundle size:Common Build Patterns
Library Mode
If building a library on top of TanStack Start:Multi-Page Application
Build multiple entry points:Build Performance
Parallel Builds
Vite builds environments in parallel by default. Control concurrency:Cache Configuration
Configure Rollup cache:Troubleshooting
Debugging Build Issues
Enable verbose logging:CommonJS Issues
If you encounter CommonJS dependency issues:Next Steps
Server Options
Configure server-side rendering options
Deployment
Deploy your TanStack Start application