StaticSite
Source:
src/AWS/Website/StaticSite.ts
Deploy a static website to S3 and CloudFront using KV-based edge routing.
StaticSite uploads site files to a private S3 bucket, creates a CloudFront
KeyValueStore with a file manifest for edge routing, and optionally builds
the site first. Supports standalone distribution or composition with
AWS.Website.Router.
Basic Sites
Section titled “Basic Sites”const site = yield* StaticSite("Docs", { path: "./site",});Built Sites
Section titled “Built Sites”const site = yield* StaticSite("Web", { path: "./frontend", build: { command: "bun run build", output: "dist", env: { VITE_API_URL: api.url, }, },});Single-Page Applications
Section titled “Single-Page Applications”// Misses fall back to index.html with a 200 so the client router// can handle the path.const site = yield* StaticSite("App", { path: "./app", build: { command: "bun run build", output: "dist", }, spa: true,});Custom Domains
Section titled “Custom Domains”const site = yield* StaticSite("Web", { path: "./site", domain: { name: "www.example.com", hostedZoneId: zone.hostedZoneId, }, errorPage: "404.html",});Router Composition
Section titled “Router Composition”Serve Through A Router
const site = yield* StaticSite("Docs", { path: "./docs", domain: { router, path: "/docs", },});Host-Matched Router Attachment
// The site serves for docs.example.com on the router. On a same-stack// router that owns a domain, this declaration alone provisions the// hostname end-to-end: the site binds it onto the router's distribution// (alias), certificate (SAN), and Route 53 record set. Wildcard// patterns and cross-stack router refs register KV host-matching only —// those hostnames must be covered by the router's own domain.const site = yield* StaticSite("Docs", { path: "./docs", domain: { name: "docs.example.com", router, },});