server-env-in-shared-code
This fails the run. Where it is wrong about your code, // ramonda-check-ignore <reason> on the line says so, and the reason is printed on every run.
Reported when process.env is read from a member the browser also runs, where process does not exist.
process.env is the SERVER's half of the environment. A component's members are not the
server's: render() runs on both sides, so does a field initialiser, and @created,
@mounted and @destroyed default to shared. Only { env: "server" } says otherwise.
So either read it where the server is, and keep the answer:
@state private region = "";
@created({ env: "server" }) read() { this.region = process.env.REGION ?? ""; }
@state is serialised into the page, so the browser reads back what the server decided and
hydration agrees.
Or, if the value is not a secret, publish it deliberately: rename it RAMONDA_PUBLIC_REGION
and read import.meta.env.RAMONDA_PUBLIC_REGION, which both bundlers compile into a literal
on both sides. The prefix is how a variable is marked safe to ship — see /reference/build.
A read at module scope, outside a class, is not reported: a server entry legitimately has one, and whether a module reaches the client bundle is a question about imports rather than about the line.
Next
- All rules — the other checks this one runs beside.
- Checking your app — how to run it, and what it proves.