Skip to main content
Netlify is a modern web hosting platform that provides instant deployments, automatic HTTPS, and powerful build tools. TanStack Start applications can be deployed to Netlify with the official Vite plugin.

Prerequisites

  • A Netlify account (sign up here)
  • Node.js and pnpm (or npm/yarn) installed
  • A TanStack Start application

Quick Start with CLI

The fastest way to deploy is using the Netlify CLI:

1. Install Plugin

Install the official Netlify plugin for TanStack Start:

2. Update Vite Config

Add the Netlify plugin to your vite.config.ts:

3. Deploy

Use the Netlify CLI to deploy:
If this is a new project, you’ll be prompted to:
  • Link or create a new site
  • Configure build settings (automatically detected)
For production deployment:

Benefits of the Netlify Plugin

The @netlify/vite-plugin-tanstack-start plugin provides:
  • Automatic build configuration for Netlify deployment
  • Full platform emulation in local development
  • Edge Functions support out of the box
  • Image optimization integration
  • Environment variables handling

Manual Configuration

If you prefer manual configuration, create a netlify.toml file:
You can also configure these settings directly in the Netlify dashboard under Site settings > Build & deploy.

Environment Variables

In Netlify Dashboard

  1. Go to Site settings > Environment variables
  2. Add your variables
  3. Choose the deploy context (production, preview, or branch)

In netlify.toml

Accessing Variables

Environment variables are available in your server functions:

Deployment Methods

Netlify supports multiple deployment workflows:

Git-Based Deployment

  1. Push your code to GitHub, GitLab, or Bitbucket
  2. Connect your repository in the Netlify dashboard
  3. Netlify automatically deploys on every push
Benefits:
  • Automatic deployments on git push
  • Deploy previews for pull requests
  • Rollback to any previous deployment

CLI Deployment

Deploy directly from your terminal:

Continuous Deployment

Netlify automatically builds and deploys when:
  • You push to your main branch (production)
  • You open a pull request (deploy preview)
  • You push to any branch (branch deploys, if enabled)

Build Configuration

Build Commands

Configure build commands in netlify.toml:

Post-Processing

Disable Netlify post-processing if needed:

Advanced Features

Netlify Edge Functions

The Netlify plugin automatically configures your server functions to run on Netlify Edge Functions for optimal performance.

Headers Configuration

Custom headers in netlify.toml:

Redirects and Rewrites

Split Testing

A/B test different branches:

Deploy Previews

Netlify automatically creates deploy previews for pull requests:
  1. Open a pull request
  2. Netlify builds and deploys a preview
  3. Preview URL is posted as a comment
  4. Test changes before merging

Configure Deploy Previews

Custom Domains

Add a Custom Domain

  1. Go to Site settings > Domain management
  2. Click Add custom domain
  3. Follow DNS configuration instructions
Netlify automatically provisions SSL certificates.

Domain Configuration in netlify.toml

Performance Optimization

Asset Optimization

Netlify automatically optimizes:
  • Image compression
  • CSS and JavaScript minification
  • Brotli compression

Caching

Control caching with headers:

Monitoring and Analytics

Netlify provides built-in analytics:
  1. Go to Analytics in your site dashboard
  2. Enable Netlify Analytics (paid feature)
  3. View traffic, top pages, and more

Resources

Troubleshooting

Build Failures

If your build fails:
  • Check the build logs in Netlify dashboard
  • Verify Node.js version: add NODE_VERSION = "20" to build environment
  • Ensure all dependencies are in package.json
  • Clear cache and retry: Deploys > Trigger deploy > Clear cache and deploy site

Function Errors

For server function issues:
  • Check Functions tab in Netlify dashboard for logs
  • Verify environment variables are set correctly
  • Test locally with the Netlify plugin’s emulation

Deploy Preview Issues

If deploy previews aren’t working:
  • Check Site settings > Build & deploy > Deploy contexts
  • Ensure deploy previews are enabled
  • Verify branch deploy settings

Domain Issues

For custom domain problems:
  • Verify DNS records are configured correctly
  • Wait for DNS propagation (can take up to 48 hours)
  • Check Site settings > Domain management for status
  • Ensure domain is not already used by another Netlify site