Skip to content

StaticSite

Source: src/Hetzner/Website/StaticSite.ts

A Hetzner Service that serves static assets built by a shell command.

StaticSite runs a build command (e.g. npm run build), packs the output directory into the unit archive, and deploys a tiny static-file server (GET assets, /health, optional SPA / 404-page). Use this when your site has its own build step — Hugo, Zola, Eleventy, or any custom pipeline.

For Vite-based projects, prefer Hetzner.Website.Vite.

Dev and Build carry constant logical ids, so they are namespaced under id. The Service stays in the caller’s namespace (same as Cloudflare.Website.StaticSite).

Deploying a Hugo site

const site = yield* Hetzner.Website.StaticSite("Blog", {
command: "hugo --minify",
outdir: "public",
});

SPA-style routing

const site = yield* Hetzner.Website.StaticSite("App", {
command: "npm run build",
outdir: "dist",
spa: true,
});
const site = yield* Hetzner.Website.StaticSite("Web", {
cwd: "apps/web",
command: "npm run build",
outdir: "dist",
});
const site = yield* Hetzner.Website.StaticSite("App", {
command: "npm run build",
outdir: "dist",
dev: { command: "npm run dev" },
});