Static generation

Decrypt during generation and deploy static files.
← Back to Nuxt

For a static site, decrypt your production file while generating pages:

{
  "scripts": {
    "generate": "dotenvx run -f .env.production --strict -- nuxt generate"
  }
}

Make DOTENV_PRIVATE_KEY_PRODUCTION available to the build job. An Enclaved Key assigned only to your server does not automatically give that job access.

$ npm run generate
$ pnpm generate

Deploy .output/public to your static host. There is no Node server or npm start step, and the static host does not need your private key.

The example's Hello Production response is captured during generation. Server routes are unavailable on the deployed static site, so later API calls need a separate backend.

Values returned into generated HTML or payloads are public. Keep real secrets in build-side code and return only data intended for visitors. Updating captured values requires generating and deploying again.

See Nuxt static hosting.

Open page ↗

Side path