Next.js environment variables in production
.env files are never uploaded to EasyHost. Here is how to set variables for Next.js, and when each one takes effect.
How Next.js reads variables
Variables prefixed with NEXT_PUBLIC_ are inlined into browser code during next build, so set them before you deploy. Server code reads the rest at runtime.
Set your variables
npx ezhst env set NEXT_PUBLIC_SITE_URL=https://my-app.easyhost.fun npx ezhst env import .env npx ezhst env list npx ezhst redeploy
Variables apply on the next deploy or redeploy.
What EasyHost provides
| Variable | Value | Available |
|---|---|---|
NODE_ENV | production | When the app runs, not during install or build |
PORT | 3000 | Build and runtime |
HOST | 0.0.0.0 | When the app runs |
HOSTNAME | 0.0.0.0 | Build and runtime |
Your own variables are available in both the build and the running app.
Common problems
- Variable is undefined because it was only in a
.envfile - A public variable is undefined in the browser because it changed after the build
See the Next.js hub for every Next.js guide, or free Next.js hosting for what is included.
Frequently asked questions
Are my .env files uploaded?
No. ezhst deploy skips every .env* file. Use ezhst env set or ezhst env import.
Start for free
Install the skill, choose Global or Local, then tell your agent to deploy. No credit card, no config files.
npx ezhst skill install