Skip to content

Node.js and Bun backends

Deploy a Fastify app on Enzonic

Deploy runs a Fastify app as a long-lived Node.js server. It builds with your build script if there is one and starts your start command with PORT and HOST set, so the usual fastify.listen call works unchanged.

At a glance

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

Language
JavaScript / TypeScript
Detected from
fastify in dependencies; A start script, a main field, or a server.js / index.js / app.js entry file
Build command
Your build script, if any
Output
The project folder
Runs as
Server

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

  • Server

    Always.

Deploy Fastify step by step

  1. 1Listen on process.env.PORT with host 0.0.0.0.
  2. 2Connect the repository and deploy.
server.js
import Fastify from 'fastify';

const app = Fastify({ logger: true });
app.get('/health', async () => ({ ok: true }));

await app.listen({ port: Number(process.env.PORT ?? 3000), host: '0.0.0.0' });

Connect a database to Fastify

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.

server.js (plugin)
import fastifyPostgres from '@fastify/postgres';

app.register(fastifyPostgres, { connectionString: process.env.DATABASE_URL });

app.get('/posts', async () => {
  const { rows } = await app.pg.query('select id, title from posts limit 20');
  return rows;
});

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

  • Fastify defaults to 127.0.0.1; without host: '0.0.0.0' the app starts but receives no traffic.

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 Fastify
LimitFreePro
Build minutes3,000/mo, 1 concurrent10,000/mo, 3 concurrent
Servers1 instance, 512 MB, sleeps after 15 min idle3 always-on, 2 GB
Bandwidth150 GB/mo2 TB/mo

Compare every plan

Related guides

Ship your Fastify project tonight

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

Start free