Contents
Static Generation
The @carats/ssg package prerenders a Carats application to static HTML, which is useful for sites that do not need a live server.
The Script
Add the static build script to package.json. It runs the carats-ssg binary with NODE_ENV=production, so the same build pipeline produces the static output.
{
"scripts": {
"build:static": "cross-env NODE_ENV=production carats-ssg"
}
}
The `carats-ssg` binary comes from the `@carats/ssg` package, which is why it is a runtime dependency rather than a dev dependency: the prerendered output is a deployment artifact.
When to Use It
Content that is the same for every visitor, such as marketing pages and documentation.
- Deployments that only need a CDN or a file host.
- Sites that still need per-request data should use the Express integration instead, because a culet may depend on the request.
The carats-ssg binary ships no TypeScript declarations of its own; treat it as a command-line tool and keep the framework types in @carats/ssr.
A culet may read cookies, headers or the query string. Any route backed by such a culet cannot be meaningfully prerendered, because the output would be frozen with one visitor's data. Keep those routes on the SSR build, or mark the consuming component with `{ recast: true }` and accept that the static output holds placeholder data.