MACRO_SECRET_KEY by default) — never in macro.config.js or the browser bundle. See Keys model. What gets injected
- Live body values for marked
data-macro-keynodes - Page SEO for
data-macro-seoslots data-macro-ssr="true"on stamped elements so the SDK skips the hydration flash
Vite plugin
Enable on the Vite plugin. Runs after vite build via closeBundle against outDir.
import { defineConfig } from 'vite'
import { macro } from '@macrocontent/sdk/vite'
export default defineConfig({
plugins: [
macro({
config: '/macro.config.js',
prerender: {
enabled: true,
locale: 'en',
apiKeyEnv: 'MACRO_SECRET_KEY',
},
}),
],
})CLI
For non-Vite pipelines or post-build steps, use the macro-prerender binary from @macrocontent/sdk:
# From a site directory that has macro.config.js
pnpm exec macro-prerender . --out dist --locale en Programmatic API: prerenderDirectory from @macrocontent/sdk/node (also fetchLiveValues, fetchPageSeo, injectLiveContentIntoHtml).
Options
| Name | Type | Required | Description |
|---|---|---|---|
enabled | boolean | optional | Vite: run after build when true. |
locale | string | optional | Content locale; falls back to defaultLocale in macro.config.js. |
apiKeyEnv | string | optional | Env var holding the server key. Default 'MACRO_SECRET_KEY'. |
configFile | string | optional | Path to macro.config.js when not at the default location. |
Publish first
Edit in draft
Editors change content in the overlay. Draft values are not what prerender reads.
Publish to live
Publish so Content API live reads see the new values. See Editors · Draft, live & publish.
Rebuild
Run your production build (or CI) with the secret set so HTML is stamped again.
Offline exit
Leaving macrocontent entirely? Export a macrobundle and bake into static HTML without calling the API.