---
title: Example: Next.js
slug: hosty/example-nextjs
icon: {"faIcon":"fa-brands fa-node-js"}
createdAt: 2026-11-08T11:27:49.007Z
---

A Next.js site in the `nextjs` folder of the project, with secrets written by CI into `.env.secrets`. See [Project configuration](https://wiki.systemseed.com/hosty/project-configuration) for all settings.

```yaml
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: production
```

Things 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.
