Back to blog

Shipping WebAssembly in a Static Export

How I kept a WASM-heavy demo compatible with Next.js static export and GitHub Pages.

The constraint was simple. Keep portfolio deployable with output: 'export' but still ship binary modules and performance demos. Pushed implementation toward build-time discovery, plain public assets, server-only filesystem access.

Static export pipeline diagram

Routes need to be deterministic

Static export only works when every route exists at build time. Post discovery, tag discovery, metadata generation - all happen from filesystem before export.

Normalize dates and tags early

Dates in frontmatter as YYYY-MM-DD. Date-only fields. Normalize in one place to avoid timezone drift between local builds and CI. Tag labels stay human-readable. URLs use slugified values. Next.js becomes next-js.

const normalizedDate = new Date(Date.UTC(year, month - 1, day))

const tagSlug = tag
  .trim()
  .toLowerCase()
  .replace(/[^a-z0-9]+/g, '-')

Keep presentation separate from routing.

Public assets over imports

Blog media lives under /public/blog/... not imported inside MDX. Keeps content format small. Avoids another layer of MDX bundling rules.

Framework details in Next.js static export docs.