Guides

Next.js

Run a Next.js app as a Node server — standalone output, env vars, health check and common failures.

Create the app

  1. 1Apps → New app, pick the repository. With next in package.json, detection suggests “Node service (Next.js)”.
  2. 2Choose Node.js Application. Defaults: install by lockfile (npm ci), build npm run build, start npm start, health check path /.
  3. 3Add your secrets, then Deploy.
package.json
{
  "scripts": {
    "dev": "next dev",
    "build": "next build",
    "start": "next start"
  }
}

How it runs

  • Shipyard asks Next for a standalone build automatically — you don’t need output: "standalone" in next.config.
  • When .next/standalone/server.js is produced, Shipyard copies .next/static and public into it and runs HOSTNAME=0.0.0.0 node server.js. The PORT it assigns is injected, and the bundle is much smaller than a full node_modules.
  • If no standalone output is produced, it publishes the whole app (devDependencies pruned) and runs your Start command.
With the standalone bundle your Start command is NOT used. Anything you chained onto it, such as npx prisma migrate deploy && npm start, doesn’t run. Run migrations some other way, or make sure they’re safe to run from the app itself.

Environment variables

  • Server code (route handlers, server components, API routes) reads process.env at runtime; secrets are injected when the container starts.
  • NEXT_PUBLIC_* variables are inlined into the browser bundle by next build. Secrets are available to the build too, but set them BEFORE deploying and redeploy after any change.

Health check

  • Before a release takes traffic, Shipyard requests the health check path (default /) until it answers with a 2xx or 3xx. A redirect from / to /login counts as healthy.
  • If / returns 404 in your app, set Settings → Runtime configuration → Health check path to a route that exists, or add one.

Common failures

  • “Health check returned 404 (app is running)” — the app is up but / isn’t a page. Change the Health check path or add the route.
  • “App didn’t respond on its assigned port” — usually a crash on boot. The app’s last output lines are in the deploy log; a missing env var or database URL is the usual cause.
  • “Build output is too large” — usually the standalone bundle wasn’t produced, so the full app was packaged. Add output: "standalone" to next.config and remove large files that aren’t needed at runtime.
  • “TypeScript errors stopped the build” / “Lockfile is out of date” — run npm run build or npm install locally, fix, commit, push.