Log inStart free
← Guides

Deploy Next.js

Deploy a Next.js app to Aloof in a few minutes. You need the CLI (curl -fsSL https://www.aloof.si/cli/aloof -o aloof && chmod +x aloof) and an account (aloof signup you@example.com, free tier, no card).

1. Generate config

aloof launch detects Next.js from package.json with next and writes a Dockerfile (unless you have one), aloof.toml and .dockerignore.

$ aloof launch --name my-nextjs

2. Review aloof.toml

app = "my-nextjs"
primary_region = "eu-de"

[http_service]
  internal_port = 8080
  auto_stop_machines = true
  min_machines_running = 0

[processes]
  web = "npm run start"

Aloof sets PORT=8080. With min_machines_running = 0 the app sleeps when idle and you pay per second only while it runs.

3. Database (optional)

$ aloof pg create my-nextjs-db --plan pg-dev
$ aloof pg attach my-nextjs-db my-nextjs     # sets DATABASE_URL over the private network

4. Deploy

$ aloof deploy
live: https://my-nextjs.aloof.si/

The directory is uploaded (respecting .dockerignore) and built remotely. New instances must pass their health check before the old ones stop.

Notes for Next.js

HOSTNAME=0.0.0.0 is set so next start listens on all interfaces. For smaller images use output: "standalone". Call internal APIs over http://<app>.internal:8080 from server code.

Next