Configuration
Create a pareto.config.ts in your project root to customize Pareto’s behavior.
import type { ParetoConfig } from '@paretojs/core'
const config: ParetoConfig = { // options}
export default configParetoConfig type
Section titled “ParetoConfig type”interface ParetoConfig { appDir?: string outDir?: string wkWebViewFlushHint?: boolean}Options
Section titled “Options”appDir
Section titled “appDir”The directory containing your route files. Defaults to app.
outDir
Section titled “outDir”The output directory for production builds. Defaults to .pareto.
wkWebViewFlushHint
Section titled “wkWebViewFlushHint”Inject a hidden element with 200+ zero-width characters into the HTML shell to force iOS WKWebView to begin rendering before the stream completes. WebKit delays first paint until visible text exceeds 200 characters, which can cause a white flash for minimal-text pages loaded inside native iOS apps. Has no visual effect and is ignored by screen readers. Only relevant for WKWebView — Safari and Chrome browsers are not affected. Defaults to false.
Customizing Vite
Section titled “Customizing Vite”Pareto uses Vite natively. To customize Vite, create a standard vite.config.ts in your project root — Pareto loads and merges it automatically in both dev and build modes.
import { defineConfig } from 'vite'import tsconfigPaths from 'vite-tsconfig-paths'
export default defineConfig({ plugins: [tsconfigPaths()], resolve: { alias: { '@': '/src' }, }, ssr: { noExternal: ['some-esm-only-pkg'], external: ['heavy-library'], },})To apply config conditionally for client vs server builds, use Vite’s native isSsrBuild flag:
export default defineConfig(({ isSsrBuild, command }) => ({ plugins: [ // Client-only plugin !isSsrBuild && clientOnlyPlugin(), ].filter(Boolean),}))Use cases:
- Adding Vite plugins (Tailwind, SVG imports, tsconfig-paths, etc.)
- Configuring SSR externals for Node.js-only packages
- Adding path aliases (
resolve.alias) - Modifying the dev server proxy settings
See the Vite config reference for all available options.
Environment variables
Section titled “Environment variables”Pareto uses Vite’s built-in environment variable handling. Variables prefixed with VITE_ are exposed to client-side code:
VITE_API_URL=https://api.example.com # Available on client and serverDATABASE_URL=postgres://localhost/mydb # Server onlyAccess them in your code:
// Client and serverconst apiUrl = import.meta.env.VITE_API_URL
// Server only (loaders, resource routes)const dbUrl = process.env.DATABASE_URLVite supports .env, .env.local, .env.development, and .env.production files. See the Vite env docs for the full loading order.
CLI Commands
Section titled “CLI Commands”pareto dev # Start dev server with HMRpareto build # Build for productionpareto start # Start production serverDev options
Section titled “Dev options”pareto dev --port 8080 # Custom port (default: 3000)pareto dev --host 0.0.0.0 # Expose to networkBuild options
Section titled “Build options”pareto build # Build for productionProduction options
Section titled “Production options”pareto start # Start production server (default port: 3000)pareto start --port 8080 # Custom portPort configuration
Section titled “Port configuration”The default port is 3000. You can change it in three ways, listed by priority (highest first):
- CLI flag:
pareto dev --port 8080 - Environment variable:
PORT=8080 pareto dev - Default:
3000
Production setup
Section titled “Production setup”For production deployments, build first, then start:
npm run build # Runs pareto buildnpm run start # Runs pareto startThe build step outputs (inside the configured outDir, default .pareto):
.pareto/client/— Static assets (JS, CSS, images) for CDN deployment.pareto/server/— Server bundle for the Node.js runtime
A minimal production Dockerfile:
FROM node:20-alpineWORKDIR /appCOPY package.json pnpm-lock.yaml ./RUN corepack enable && pnpm install --frozen-lockfile --prodCOPY .pareto/ .pareto/EXPOSE 3000CMD ["npx", "pareto", "start"]Related
Section titled “Related”- Resource Routes — API endpoints via
route.ts. - @paretojs/core API —
ParetoConfigtype and runtime exports.