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
- Push your app to a Git repo.
- In the dashboard, choose New Egg and connect the repo.
- 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.
// next.config.js
module.exports = {
output: 'standalone',
};web: node .next/standalone/server.jsEnvironment 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.
Caching, ISR and writable paths
An Egg runs with a read-only root filesystem, which is what keeps a running container tamper resistant. Next writes its prerender cache inside .next whenever a page revalidates, so on a read-only filesystem those writes fail and you will see EROFS: read-only file system in your logs. Nothing crashes, but the cache is not kept and the page is recomputed every time.
Give it somewhere to write: open the Egg, find Writable paths under its configuration, and add the cache directory. For a standard app that is /app/.next/cache; in a monorepo it is the app's own path, for example /app/apps/web/.next/cache. Each path gets scratch space of the size you choose. Saving rolls the Egg onto the new mount.
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.