Skip to content

Static sites and SPAs

Deploy a Vite site on Enzonic

A Vite app without a full-stack framework is a static single-page app. Deploy detects the flavour (React, Vue, Svelte, Solid, Preact or Lit), runs vite build and serves dist. Add an api/ folder for server code and it runs as functions on the same domain.

At a glance

What Enzonic Deploy does with a Vite project when you connect it. You can override any of it in the project settings.

Language
JavaScript / TypeScript
Detected from
vite in dependencies, with no full-stack framework; The UI library sets the variant: React, Vue, Svelte, Solid, Preact or Lit
Build command
vite build
Output
dist
Runs as
Static

Dependencies install with the package manager your lockfile names: npm ci, pnpm install --frozen-lockfile, yarn install --immutable (Berry) or --frozen-lockfile, or bun install --frozen-lockfile. Node.js 18, 20, 22 and 24 are available. Deploy reads engines.node in package.json, then .nvmrc or .node-version, and uses Node.js 22 when nothing pins a version.

How it runs

  • Static

    Always, plus functions for any files in api/.

Deploy Vite step by step

  1. 1Connect the repository; Vite and its variant are detected.
  2. 2Add a rewrite to index.html in enzonic.json if your router uses browser history paths.
  3. 3Deploy.
enzonic.json
{
  "rewrites": [{ "source": "/(.*)", "destination": "/index.html" }]
}
Deploy reads redirects, rewrites, headers, trailingSlash and cleanUrls from enzonic.json (a vercel.json with the same keys works too).

Connect a database to Vite

Create a database on Enzonic Databases (or from the project's settings) and its connection string is added to the project's environment variables. This example uses PostgreSQL.

api/notes.ts
import postgres from 'postgres';

const sql = postgres(process.env.DATABASE_URL!);

export async function GET() {
  return Response.json(await sql`select id, body from notes order by id desc limit 50`);
}

export async function POST(request: Request) {
  const { body } = await request.json();
  const [note] = await sql`insert into notes (body) values (${body}) returning id, body`;
  return Response.json(note, { status: 201 });
}
Export one function per HTTP method; a method you do not export answers 405.

Postgres projects get two variables: DATABASE_URL through the connection pooler for the app, and DATABASE_URL_UNPOOLED for migrations.

PostgreSQL on Enzonic DatabasesEvery database engine

Things to know

  • Only variables prefixed VITE_ reach the browser bundle, and they are fixed at build time. Secrets belong in api/ functions.

Plan limits that matter here

From the live plan data. Every plan includes previews for each branch, instant rollback, environment variables and logs.

Plan limits that matter for Vite
LimitFreePro
Build minutes3,000/mo, 1 concurrent10,000/mo, 3 concurrent
Function memory / timeout1 GB / 300 s4 GB / 1800 s
Function invocations2 M/mo20 M/mo
Bandwidth150 GB/mo2 TB/mo

Compare every plan

Related guides

Ship your Vite project tonight

Connect the repository and the build settings fill themselves in. Free plan, no card.

Start free