Skip to content

Static sites and SPAs

Deploy a Gatsby site on Enzonic

Deploy runs gatsby build and serves the public folder as a static site; installed dependencies are cached per lockfile, so repeat builds skip most of the install. Server-side features of Gatsby (SSR and DSG pages, Gatsby Functions) are not run; put API code in an api/ folder instead.

At a glance

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

Language
JavaScript / TypeScript
Detected from
gatsby in dependencies
Build command
gatsby build
Output
public
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: the public folder is served from the edge.

Deploy Gatsby step by step

  1. 1Connect the repository; Gatsby is detected from package.json.
  2. 2Add build-time variables (GATSBY_ prefix for the browser) and deploy.

Connect a database to Gatsby

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/subscribe.js
import pg from 'pg';

const pool = new pg.Pool({ connectionString: process.env.DATABASE_URL });

export async function POST(request) {
  const { email } = await request.json();
  await pool.query('insert into subscribers (email) values ($1) on conflict do nothing', [email]);
  return Response.json({ ok: true });
}
Files in api/ at the project root become functions at /api/<name>, beside the static site.

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

  • Pages using getServerData or DSG need a Gatsby server, which Deploy does not run: they must be static.

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 Gatsby
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 Gatsby project tonight

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

Start free