getEnv() is the request’s c.env. On Cloudflare that is the Worker bindings object. On Node during vite dev, the Hono adapter exposes .env files on process.env, and the request context still has an env object.
getEnv() in loaders, actions, and middleware so the same code runs on Workers. Do not sprinkle process.env through those files.
Files
Do not put secrets in
vite.config.ts or client pages. Anything referenced as import.meta.env.VITE_* is bundled for the browser.
Node vs Workers
On Workers,process.env is not your Wrangler bindings. Bindings only exist on c.env / the env argument of fetch / scheduled / queue / email.
src/worker.ts
getEnv() is that same env. In scheduled / queue / email, pass env yourself — getEnv() is request-scoped and will throw.
Client env
The browser only seesimport.meta.env.VITE_*. Use that for public values such as VITE_APP_URL. Never prefix secrets with VITE_.
.env example
.env