how to1 min readv1
Add a static site
The root site serves the pages at /. Static mode is the default and exports plain files at build time.
On this page
Generate the site
bash
pnpm nx g @empire-builder-kit/nx:site --mode=staticThe generator creates packages/site. A workspace has one root site. Static is the default mode, so --mode=static is optional.
Keep it static
The site’s Next.js configuration carries the two settings a static export needs:
next.config.ts
const config = {
output: 'export',
images: { unoptimized: true },
};- Give every dynamic route a
generateStaticParamsfunction that lists its pages. - Do not add route handlers under
app/api. Call a Slice’s API from the browser. - Read configuration from
NEXT_PUBLIC_variables at build time. There is no server to read it later.
If the build has a page it cannot export, next build fails and names the route.
Verify and deploy
bash
pnpm nx run site:verifyThe site deploys with the rest of the workspace, after the Foundation. See Deploy.
Continue building