Skip to content

Commit 6e03e4c

Browse files
jasnellvicb
andauthored
Apply suggestions from code review
Co-authored-by: Victor Berchet <[email protected]>
1 parent 91e155e commit 6e03e4c

File tree

1 file changed

+16
-6
lines changed

1 file changed

+16
-6
lines changed

src/content/docs/workers/configuration/environment-variables.mdx

Lines changed: 16 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -106,8 +106,15 @@ Select the **Secret** type if your environment variable is a [secret](/workers/c
106106

107107
## Environment variables and Node.js compatibility
108108

109-
When you enable both the [`nodejs_compat`](/workers/runtime-apis/nodejs/) and [`nodejs_compat_populate_process_env`](/workers/configuration/compatibility-flags/) compatibility
110-
flags, environment variables will also be available via the global `process.env`.
109+
When you enable both the [`nodejs_compat`](/workers/runtime-apis/nodejs/) and
110+
[`nodejs_compat_populate_process_env`](/workers/configuration/compatibility-flags/)
111+
compatibility flags, environment variables will also be available via the global
112+
`process.env`. Note that the `nodejs_compat_populate_process_env` flag is
113+
enabled automatically when `nodejs_compat` is used with a compatibility date
114+
on or after April 1st, 2025.
115+
116+
The `process.env` will be populated lazily the first time that `process` is accessed
117+
in the worker.
111118

112119
Text variable values are exposed directly.
113120

@@ -119,11 +126,14 @@ JSON string.
119126
For example, imagine a Worker with three environment variables, one text value, and
120127
two JSON values:
121128

122-
* `FOO` with plaintext value `abc`,
123-
* `BAR` with JSON value `"abc"`,
124-
* `BAZ` with JSON value `"{ "a": 123 }"`
129+
```
130+
[vars]
131+
FOO = "abc"
132+
BAR = "abc"
133+
BAZ = { "a": 123 }
134+
```
125135

126-
Environment variables can be added using either the `wrangler.{json|toml}` file or via the Cloudflare
136+
Environment variables can be added using either the `wrangler.{json|jsonc|toml}` file or via the Cloudflare
127137
dashboard UI.
128138

129139
The value of `process.env.FOO` will be the JavaScript string `"abc"`.

0 commit comments

Comments
 (0)