Skip to content

Nextjs

Source: src/Hetzner/Website/Nextjs.ts

Deploy a Next.js application to a Hetzner Cloud Server: next build then a long-running next({ dev: false }) systemd unit on port 3000. Does not use OpenNext (those wrappers are Lambda/workerd).

The .next output (and public/ when present) is packed into the unit archive. next, react, and react-dom are installed on the unit with npm install rather than bundled.

During alchemy dev the site is next dev and no cloud resources are declared; Alchemy.remote() opts back into the live Service.

Basic Next.js App

const site = yield* Hetzner.Website.Nextjs("Web", {
rootDir: "./app",
});

Custom Domain

const site = yield* Hetzner.Website.Nextjs("Web", {
rootDir: "./app",
domain: "app.example.com",
zone,
});