---
title: Access your Worker's environment variables from process.env
description: With Node.js compatibility on, process.env is automatically populated with environment variables and secrets
image: https://edgetunnel-b2h.pages.dev/changelog-preview.png
---

> Documentation Index  
> Fetch the complete documentation index at: https://edgetunnel-b2h.pages.dev/changelog/llms.txt  
> Use this file to discover all available pages before exploring further. 

[Skip to content](#%5Ftop) 

# Changelog

New updates and improvements at Cloudflare.

[ Subscribe to RSS ](https://edgetunnel-b2h.pages.dev/changelog/rss/index.xml) [ View RSS feeds ](https://edgetunnel-b2h.pages.dev/fundamentals/new-features/available-rss-feeds/) 

![hero image](https://edgetunnel-b2h.pages.dev/_astro/hero.CVYJHPAd_26AMqX.svg) 

[ ← Back to all posts ](https://edgetunnel-b2h.pages.dev/changelog/) 

## Access your Worker's environment variables from process.env

Mar 11, 2025 

[ Workers ](https://edgetunnel-b2h.pages.dev/workers/) 

You can now access [environment variables](https://edgetunnel-b2h.pages.dev/workers/configuration/environment-variables/) and [secrets](https://edgetunnel-b2h.pages.dev/workers/configuration/secrets/) on [process.env](https://edgetunnel-b2h.pages.dev/workers/runtime-apis/nodejs/process/#processenv)when using the [nodejs\_compat compatibility flag](https://edgetunnel-b2h.pages.dev/workers/configuration/compatibility-flags/#nodejs-compatibility-flag).

**JavaScript**

```js
const apiClient = ApiClient.new({ apiKey: process.env.API_KEY });
const LOG_LEVEL = process.env.LOG_LEVEL || "info";
```

In Node.js, environment variables are exposed via the global `process.env` object. Some libraries assume that this object will be populated, and many developers may be used to accessing variables in this way.

Previously, the `process.env` object was always empty unless written to in Worker code. This could cause unexpected errors or friction when developing Workers using code previously written for Node.js.

Now, [environment variables](https://edgetunnel-b2h.pages.dev/workers/configuration/environment-variables/), [secrets](https://edgetunnel-b2h.pages.dev/workers/configuration/secrets/), and [version metadata](https://edgetunnel-b2h.pages.dev/workers/runtime-apis/bindings/version-metadata/)can all be accessed on `process.env`.

To opt-in to the new `process.env` behaviour now, add the [nodejs\_compat\_populate\_process\_env](https://edgetunnel-b2h.pages.dev/workers/configuration/compatibility-flags/#enable-auto-populating-processenv) compatibility flag to your `wrangler.json` configuration:

* [  wrangler.jsonc ](#tab-panel-2937)
* [  wrangler.toml ](#tab-panel-2938)

**JSONC**

```jsonc
{
  // Rest of your configuration
  // Add "nodejs_compat_populate_process_env" to your compatibility_flags array
  "compatibility_flags": ["nodejs_compat", "nodejs_compat_populate_process_env"],
  // Rest of your configuration
```

**TOML**

```toml
compatibility_flags = [ "nodejs_compat", "nodejs_compat_populate_process_env" ]
```

After April 1, 2025, populating `process.env` will become the default behavior when both `nodejs_compat` is enabled and your Worker's `compatibility_date` is after "2025-04-01".

```json
{"@context":"https://schema.org","@type":"BlogPosting","@id":"https://edgetunnel-b2h.pages.dev/changelog/post/2025-03-11-process-env-support/#page","headline":"Access your Worker's environment variables from process.env · Changelog","description":"With Node.js compatibility on, process.env is automatically populated with environment variables and secrets","url":"https://edgetunnel-b2h.pages.dev/changelog/post/2025-03-11-process-env-support/","inLanguage":"en","image":"https://edgetunnel-b2h.pages.dev/changelog-preview.png","dateModified":"2025-03-11","datePublished":"2025-03-11","publisher":{"@type":"Organization","name":"Cloudflare","url":"https://www.cloudflare.com/"},"isPartOf":{"@type":"WebSite","@id":"https://edgetunnel-b2h.pages.dev/#website","name":"Cloudflare Docs","url":"https://edgetunnel-b2h.pages.dev/"}}
```
