System environment variables
System environment variables are local environment variables that can change Wrangler’s behavior. There are three ways to set system environment variables:
- Create an - .envfile in your project directory. Set the values of your environment variables in your- .envfile. This is the recommended way to set these variables, as it persists the values between Wrangler sessions.
- Inline the values in your Wrangler command. For example, - WRANGLER_LOG="debug" npx wrangler deploywill set the value of- WRANGLER_LOGto- "debug"for this execution of the command.
- Set the values in your shell environment. For example, if you are using Z shell, adding - export CLOUDFLARE_API_TOKEN=...to your- ~/.zshrcfile will set this token as part of your shell configuration.
 Supported environment variables
Wrangler supports the following environment variables:
- CLOUDFLARE_ACCOUNT_ID- string- The account ID for the Workers related account.
 
- CLOUDFLARE_API_TOKEN- string- The API token for your Cloudflare account, can be used for authentication for situations like CI/CD, and other automation.
 
- CLOUDFLARE_API_KEY- string- The API key for your Cloudflare account, usually used for older authentication method with CLOUDFLARE_EMAIL=.
 
- The API key for your Cloudflare account, usually used for older authentication method with 
- CLOUDFLARE_EMAIL- string- The email address associated with your Cloudflare account, usually used for older authentication method with CLOUDFLARE_API_KEY=.
 
- The email address associated with your Cloudflare account, usually used for older authentication method with 
- WRANGLER_SEND_METRICS- string- Options for this are trueandfalse, the default behavior isfalse.
 
- Options for this are 
- WRANGLER_HYPERDRIVE_LOCAL_CONNECTION_STRING_<BINDING_NAME>- string- The local connection string for your database to use in local development with Hyperdrive. For example, if the binding for your Hyperdrive is named PROD_DB, this would beWRANGLER_HYPERDRIVE_LOCAL_CONNECTION_STRING_PROD_DB="postgres://user:password@127.0.0.1:5432/testdb". Each Hyperdrive is uniquely distinguished by the binding name.
 
- The local connection string for your database to use in local development with Hyperdrive. For example, if the binding for your Hyperdrive is named 
- CLOUDFLARE_API_BASE_URL- string- The default value is "https://api.cloudflare.com/client/v4".
 
- The default value is 
- WRANGLER_LOG- string- Options for Logging levels are "none","error","warn","info","log"and"debug". Levels are case-insensitive and default to"log". If an invalid level is specified, Wrangler will fallback to the default.
 
- Options for Logging levels are 
Example .env file
The following is an example .env file:
CLOUDFLARE_ACCOUNT_ID=<YOUR_ACCOUNT_ID_VALUE>
CLOUDFLARE_API_TOKEN=<YOUR_API_TOKEN_VALUE>
CLOUDFLARE_EMAIL=<YOUR_EMAIL>
WRANGLER_SEND_METRICS=trueCLOUDFLARE_API_BASE_URL=https://api.cloudflare.com/client/v4WRANGLER_LOG=debug Deprecated global variables
The following variables are deprecated. Use the new variables listed above to prevent any issues or unwanted messaging.
- CF_ACCOUNT_ID
- CF_API_TOKEN
- CF_API_KEY
- CF_EMAIL
- CF_API_BASE_URL