Skip to content

Next.js

Wrap your Next.js scripts with hushenv run. Edit package.json:

{
"scripts": {
"dev": "hushenv run -- next dev",
"build": "hushenv run -- next build",
"start": "hushenv run -- next start"
}
}

hushenv run injects the resolved values as real environment variables before Next.js starts. Next.js does not override variables that are already set, so the injected values win — including NEXT_PUBLIC_* variables, which are inlined at build time. Wrap build as well as dev so those public variables are present during the build.

After wiring it up, render a NEXT_PUBLIC_* value on a page once to confirm the build-time inlining picked it up.

In production, set your environment variables through your host (for example, your platform’s dashboard or secret manager). hushenv is a local-development tool — you don’t need it in your production runtime.