Skip to main content
TanStack Start provides extensive server-side configuration options for SSR, server functions, and deployment targets.

Server Entry

Customize the server entry point:
Default server entry (if not specified):

Server Functions

Configure how server functions are handled:

Function ID Generation

By default, server functions receive auto-generated IDs. Customize this:

Server Function Base Path

Server functions are served from a base path:

Server Build Configuration

Configure server-side build options:

Static NODE_ENV Replacement

When staticNodeEnv is enabled (default), process.env.NODE_ENV is replaced with its actual value during build:
Disable this if you need dynamic NODE_ENV checks:

Development Server

Configure development server behavior:

SSR Styles in Development

During development, CSS modules need special handling for SSR:
Disable if you’re using a CSS-in-JS solution that doesn’t require it:

Middleware Mode

Use TanStack Start as middleware in an existing server:
Then in your server:

Server Handler

Customize the request handler:

Stream Handler

Use the default stream handler for SSR:

Custom Response Headers

Add custom headers to all responses:

Server-Only Code

Ensure code only runs on the server:

Import Protection

Prevent server-only imports from leaking to the client:
See Import Protection for more details.

Prerendering

Configure static site generation:

Page-Specific Prerender Options

Prerender Success Callback

Deployment Targets

Node.js Server

Default setup works for Node.js:

Vercel

No additional configuration needed:

Netlify

Use Netlify Edge Functions:

Cloudflare Workers

Configure for Workers runtime:

Docker

Example Dockerfile:

Custom Server Environments

Create a custom server environment for edge deployments:

Environment Variables

Load environment variables:
Public variables (prefixed with PUBLIC_) are available on the client:

Performance Optimization

Response Caching

Compression

Enable response compression:

Monitoring and Logging

Add request logging:

Error Handling

Custom error responses:

Next Steps

Server Functions

Learn how to create and use server functions

Deployment

Deploy your TanStack Start application