Skip to main content
The evidence preview command starts a local server to preview your production build.

Syntax

evidence preview

Description

This command:
  • Serves the production build from the ./build directory
  • Uses the serve package to start a static file server
  • Provides a local URL to preview your built application
  • Automatically increases Node.js memory limit to 4096MB
  • Supports both multi-page app (MPA) and single-page app (SPA) modes
The preview server allows you to test the production build locally before deploying.

Prerequisites

You must build your project before running preview:
evidence build
evidence preview

Usage Examples

Preview the production build

evidence preview
The server will start and display the local URL (typically http://localhost:3000).

SPA mode preview

VITE_EVIDENCE_SPA=true evidence preview
This serves the build in single-page application mode with client-side routing fallback.

Error Handling

If no build directory is found, you’ll see:
[!] No build directory found
Run npm run build to create a build
Exit code: 1

Server Options

The preview command uses the serve package under the hood. The exact command executed: Multi-page app (default):
npx serve build
Single-page app (SPA mode):
npx serve build -s
The -s flag enables single-page application mode, which redirects all 404s to the root index.html.

Environment Variables

VITE_EVIDENCE_SPA
boolean
default:"false"
When set to true, serves the build in SPA mode with client-side routing.
Other environment variables are loaded from .env files automatically. See Environment Variables for a complete list.

Port Configuration

The serve package automatically selects an available port. You can specify a custom port using serve’s CLI options:
evidence preview -p 8080

Exit Codes

  • 0 - Preview server started successfully
  • 1 - No build directory found
  • Non-zero - Server failed to start

Build Directory

The preview command looks for the build in:
./build/
If you used a custom build directory:
EVIDENCE_BUILD_DIR=./dist evidence build
You’ll need to manually preview that directory:
npx serve dist

Deployment Testing

The preview command is useful for testing:
  • Production build output
  • Asset loading and paths
  • Static file serving
  • Routing behavior
  • Performance characteristics
This helps catch issues before deploying to production hosting.

Build docs developers (and LLMs) love