Introducing Secrets and Environment Variables to Cloudflare Workers



Finally! Does the usage of variables consume sub-requests, just like KV does?

1 Like

KV operations also do not count against the documented per-worker subrequest limit. Note that, per the docs, they do count towards the concurrent connection limit.

(KV operations are considered “in-house” subrequests, which have a separate, undocumented limit which is high enough that the worker is unlikely to be able to hit it without first hitting the 50ms CPU limit.)


Thanks, so this means the variables have the same limits and cost as KV?

Hi @thomas4, no, environment variables are unrelated to KV. The environment variable-specific limits are documented here:

The maximum number of environment variables (secret and text combined) for an account is 32 variables.

Each environment variable has a size limitation of 1kB.

There is no additional cost to using environment variables, and they don’t involve any I/O. Instead, the environment variable is injected into the worker script’s global scope immediately prior to its top-level execution.


Great, thank you.

For us that use “secrets” on every page load, this could actually cut cost by several times over.


Can an alias for process.env.XXX be added for easier interoperability with node?