Next.js static export

With output: "export", next build writes plain HTML to out. Run Headlark on that folder before it's deployed.

1. Turn on static export

// next.config.mjs
export default {
  output: "export",
};

2. Install and add it to your build script

npm i -D headlark
// package.json
"scripts": {
  "build": "next build && headlark out --site-url https://example.com"
}

out/about.html becomes https://example.com/about; with trailingSlash: true, out/about/index.html becomes https://example.com/about/. With a basePath, add it to the address: --site-url https://example.com/docs/. The 404 page is left alone.

3. Add your key

Set HEADLARK_KEY to your site's secret key from the dashboard in the build environment.

HEADLARK_KEY=sk_... npm run build

Good to know