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
- 1Listen on process.env.PORT with host 0.0.0.0.
- 2Connect the repository and deploy.
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.
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 engineThings 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.
| Limit | Free | Pro |
|---|---|---|
| Build minutes | 3,000/mo, 1 concurrent | 10,000/mo, 3 concurrent |
| Servers | 1 instance, 512 MB, sleeps after 15 min idle | 3 always-on, 2 GB |
| Bandwidth | 150 GB/mo | 2 TB/mo |
Related guides
- Deploy a Express appExpress (and Koa) apps as a Node.js server.
- Deploy a Hono appHono APIs on Node.js or Bun as a long-lived server.
- Deploy a NestJS appNestJS APIs compiled with nest build and started from dist/main.js.
Ship your Fastify project tonight
Connect the repository and the build settings fill themselves in. Free plan, no card.