Documentation Sign in to the Console

Server apps

Run your own server (Express, Fastify, Next.js, Nuxt, SvelteKit) from GitHub, with zero-downtime deploys and automatic restarts.

A server app is a site that runs its own Node.js server instead of being served as files. Use it when your app renders pages on the server, has API routes, or keeps connections open.

Create a server app

  1. In Sites › Create site, choose GitHub and pick the repository and branch.
  2. In App settings, under How it runs, choose Server app.
  3. Leave Start command empty to use your start script, or enter one, such as node dist/server.js.
  4. Set the Health check path, such as /health. Any answer below 500 counts as healthy.
  5. Choose Save and deploy.

What your app needs

  • Listen on PORT. Start your server on process.env.PORT (8080).
  • A package.json, with a start script or a server.js / index.js.
  • Read-only files. The app's folder can't be written to. Keep uploads and data in a database, and temporary files in /tmp.

Requests arrive with x-forwarded-host, x-forwarded-for and x-forwarded-proto set to the visitor's address, IP and https.

js
import express from "express";
const app = express();
app.set("trust proxy", true);
app.get("/health", (req, res) => res.send("ok"));
app.get("/", (req, res) => res.send(`Hello from ${req.hostname}`));
app.listen(process.env.PORT);

How the start command is worked out

Your app Start command
A start script in package.json npm start
Nuxt node .output/server/index.mjs
SvelteKit with adapter-node node build
main in package.json node <main>
A server.js, index.js or app.js node <file>

The build installs your packages, runs your build script, then removes development packages before the app starts.

Zero-downtime deploys

Every push to the production branch builds a new version. It starts beside the version serving visitors, and takes over only once every instance answers the health check.

Important

A version that doesn't answer within 60 seconds never goes live. The deploy fails with the app's last log lines, and the running version keeps serving.

Rolling back, changing a setting or a secret, and changing the start command all work the same way.

Instances and restarts

  • An app runs 1 to 4 instances that share visitors in turn, depending on your plan. With two or more, the app stays up while one restarts.
  • A crashed instance restarts at once. One that stops answering its health check three times in a row (every 30 seconds) is replaced.

Change these on the site's App tab.

Limits

Limit Value
Memory per instance 512 MB
CPU per instance Half a CPU
App size with packages 1 GB, 200,000 files
Request time 60 seconds
Server apps per team Starter 1, Pro 3, Agency 10
Instances per app Starter 1, Pro 2, Agency 4

Pull request previews aren't available for server apps yet.