DocsNext.js

Next.js

Deploy a Next.js app on Ruust: App Router or Pages Router, built and served on HTTPS.

Ruust detects a Next.js app from the next dependency in your package.json, runs next build, and starts it with next start. Both the App Router and the Pages Router work, and server components, route handlers and middleware all run because your Egg is a real always-on Node server, not a set of functions.

Deploy it

  1. Push your app to a Git repo.
  2. In the dashboard, choose New Egg and connect the repo.
  3. Pick a size and a region, then lay the Egg. Ruust builds and hatches it on HTTPS.

The port

next start reads the PORT environment variable and binds to 0.0.0.0 for you, so there is nothing to configure. Ruust sets PORT; Next listens on it.

A leaner image with standalone output

Optional, but recommended for faster builds and smaller images: turn on standalone output. Next then emits a self-contained server you can run directly.

javascript
// next.config.js
module.exports = {
  output: 'standalone',
};
Emit a standalone server bundle.
text
web: node .next/standalone/server.js
Point the start command at the standalone server with a Procfile. Reading the repo-root `web:` line is a Nixpacks feature, so it depends on the build using Nixpacks (which bakes the line into the image at build time); it is not a Ruust-side guarantee and is ignored when you supply your own Dockerfile.

Environment variables

Set server-side variables (database URLs, API keys) on the Egg; they are available at build and run time and never printed in logs. Anything the browser needs must be prefixed NEXT_PUBLIC_ and is baked in at build time, so set those before you deploy and redeploy after changing them.

Custom domains

Every Egg gets a ruust.run URL immediately. To serve your own domain, add it under the Egg and point the DNS record we show you; Ruust issues and renews TLS automatically. See Custom domains.