Skip to content

Node.js and Bun backends

Deploy a Node.js functions app on Enzonic

Put .js or .ts files in api/ and each one becomes an endpoint at /api/<file>. Functions start on demand, stay warm for a few minutes and scale with traffic, so you pay nothing in idle time. The same api/ folder also works next to any static framework.

At a glance

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

Language
JavaScript / TypeScript
Detected from
Files in api/*.js or api/*.ts, with no server framework entry point
Build command
None by default
Output
api/ plus public/ for static files
Runs as
Functions

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

  • Functions

    Always. Instances stay warm for 5 minutes on Free and 15 minutes on paid plans after a request.

Deploy Node.js functions step by step

  1. 1Create api/hello.ts exporting a GET function.
  2. 2Optionally add public/ for static files.
  3. 3Connect the repository and deploy.
api/hello.ts
export function GET(request: Request) {
  const name = new URL(request.url).searchParams.get('name') ?? 'world';
  return Response.json({ hello: name });
}
A function module can export HTTP method handlers (GET, POST, ...), a default function, a default object with fetch(), or a Node-style handler(req, res).

Connect a database to Node.js functions

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/users.ts
import postgres from 'postgres';

// Created once per warm instance and reused across requests.
const sql = postgres(process.env.DATABASE_URL!, { max: 1 });

export async function GET() {
  return Response.json(await sql`select id, name from users limit 50`);
}

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

  • Function memory and maximum duration come from your plan; long jobs belong in a server project.
  • Keep a small connection pool per instance (max: 1 or 2): many warm instances share one database.

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 Node.js functions
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 Node.js functions project tonight

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

Start free