Example: Next.js
1 min
A Next.js site in the nextjs folder of the project, with secrets written by CI into .env.secrets. See Project configuration for all settings.
clusterName: <cluster>
clusterRegion: eu-west-2
projectName: example
applications:
nextjs:
type: node
appRoot: ./nextjs
node:
version: "24"
environmentVariables:
FRONTEND_URL: "https://{{ nextjs.host.0 }}"
APP_MODE: development
environmentFiles:
- ./.env.secrets
hooks:
build: |
npm ci
npm run build
run: |
npm run start
overrides:
- condition:
environments: [production]
hosts:
- example.com
node:
environmentVariables:
APP_MODE: productionThings to know:
- next start listens on port 3000, which Hosty expects for Node.js.
- The load balancer checks /.healthz and needs a 200 or 204 answer. Add a route for it, i.e. a rewrite of /.healthz to an API route in next.config.js.
- The code is read-only. Next.js writes its cache into .next/cache at runtime, i.e. for optimised images. If your site needs it, add readOnlyCode: false to the application.
- NEXT_PUBLIC_* variables are built into the JavaScript by npm run build. They come from the variables of the node container, which the build hook has.