BlogExpress

How to deploy an Express API with a database.

An Express API deploys with one sentence. It needs a start script, it must read PORT, and it can use the Postgres database Antideploy creates.

How the Agent API works
  • npm run startNeeds a start script in package.json
  • PORTRead it and listen on 0.0.0.0
  • DATABASE_URLSet for you when you need Postgres
  • Migrations runPrisma and Drizzle commands are detected

The short answer

To deploy an Express API, give your coding agent the sentence below. Antideploy finds Express in your package.json, runs npm run start, and sends traffic to the port in the PORT variable. If your code needs Postgres, it creates a database and sets DATABASE_URL. You need three things in your code: a start script, a server that reads PORT, and a database connection that reads DATABASE_URL.

Say this to your coding agent

Set this project up to deploy on Antideploy. Fetch https://antideploy.com/agent.md and follow it.

What Antideploy detects

  • Express. Detected from the express dependency. Fastify, Koa, NestJS and hapi are detected the same way.
  • The start command. A Procfile web: line wins. Otherwise Antideploy runs your start script with npm run start. Without either, it cannot tell how to run the app and says so.
  • The port. It starts your app with PORT set. Your code must use it.
  • The versions. The Node.js version comes from engines.node in package.json, a .nvmrc or a .node-version file.
  • The database. A pg, postgres, @neondatabase/serverless or @vercel/postgres dependency, or Prisma or Drizzle, means Postgres.

What your code needs

server.js
import express from "express";
import pg from "pg";

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

app.get("/health", (req, res) => res.send("ok"));

const port = process.env.PORT || 3000;
app.listen(port, "0.0.0.0");
package.json
{
  "scripts": { "start": "node server.js" }
}

If you write TypeScript, add a build script that compiles it and point start at the compiled file, for example node dist/server.js. A start script that needs a tool kept only in devDependencies, such as tsx or ts-node, can fail, because development dependencies are removed from the image after the build.

Step by step

  1. Check the three things

    Your project has a start script, the server reads PORT, and the database is read from DATABASE_URL.

  2. Paste the sentence and approve one link

    Your agent creates the app, and a Postgres database if your code needs one, and writes the connection details into your .env without printing them. The same database serves local testing and the live app.

  3. Deploy and open the link

    Antideploy installs with npm ci when there is a package-lock.json, runs your build, runs your migration command if it found one, starts the app, checks that it answers and opens it.

Migrations

If you use an ORM with migrations, Antideploy detects the command and runs it before the new version goes live. A failed migration fails the deploy, so a broken schema never goes live.

  • Prisma runs npx prisma migrate deploy when you have a migrations folder, and npx prisma db push when you do not
  • Drizzle runs npx drizzle-kit migrate
  • If a migration fails because prisma or drizzle-kit is not found, move it into dependencies in package.json

Common problems

01Before you commit

Here's where it stops.

A platform that only tells you what it is good at is one you find the edges of in production. These are the ones to know before your first deploy.

  1. Apps sleep when idle

    On every plan, an app nobody is using goes to sleep and the next visit wakes it. The first request took 2.9 to 13.9 seconds in our measurements, depending on the stack. There are no always-on workers, so use a cron job or a webhook for background work.

  2. One instance, no previews

    Each app is one instance with 1 shared vCPU and 1 GB of memory, and a Java app gets 1 dedicated vCPU and 2 GB. There are no preview deployments and no per-branch URLs.

  3. The disk forgets

    Anything written to local disk is gone on the next deploy. Apps that speak S3 get a bucket instead.

  4. No background workers

    Only the web process runs. A queue consumer or a loop inside the app will not stay alive. Use a cron job to call a path on a schedule, or a webhook.

02Questions

Express questions, answered.

Anything else? Write to us and a person answers.

support@antideploy.com
Do I need a Dockerfile for Express?

No. Antideploy builds it from your project. If you add a Dockerfile at the root, it is used instead.

Can I use MongoDB or MySQL with Express?

Antideploy creates Postgres only. You can use another database from another provider and set its connection string as a variable.

Does Express work with WebSockets?

Yes. Each app is one long-running process, and Antideploy sets no time limit of its own on a connection.

What does it cost?

An Express API with a server counts as one live app. The Free plan includes 1 live app with a server and 1 Postgres database.

Deploy something. Start with one sentence.

Paste one sentence into your coding agent, click Approve once, and get a live link. No card, no trial clock.

Start from GitHub or a folder
Prompt copied Paste it into Claude Code, Codex or Cursor and press Enter.