Skip to main content
TanStack Start uses Vite’s environment API to build separate client and server bundles. This guide covers build-specific configuration options.

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
Each environment can be configured independently through Vite’s environments configuration.

Output Directories

By default, TanStack Start outputs builds to:
You can customize output directories:

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

Replace process.env.NODE_ENV at build time for dead code elimination:
When enabled, 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’s builder API:

Environment-Specific Configuration

Use different settings per environment:

Build Analysis

Analyze your bundle size:
Run build and open the generated stats.html file.

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