Skip to content

StaticSite

Source: src/Fly/Website/StaticSite.ts

Deploy a static site built by a shell command to Fly.

StaticSite runs a build command (e.g. npm run build / hugo), content-hashes the output directory, and deploys a Service that serves those files (plus /health). Use this when the site has its own build step — Hugo, Zola, Eleventy, or any custom pipeline.

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

Build / Dev use constant logical ids under Namespace.push(id). The Service stays in the caller namespace (same as Cloudflare.Website.StaticSite).

Deploying a Hugo site

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

SPA-style routing

const site = yield* Fly.Website.StaticSite("App", {
build: { command: "npm run build", output: "dist" },
assets: { notFoundHandling: "single-page-application" },
});
const site = yield* Fly.Website.StaticSite("Web", {
path: "apps/web",
build: { command: "npm run build", output: "dist" },
});
const site = yield* Fly.Website.StaticSite("App", {
build: { command: "npm run build", output: "dist" },
dev: { command: "npm run dev" },
});