Prompt Buddy logoPrompt Buddy

cloudflare · Cloudflare Workers Docs

Workers Environment variables and secrets

Configuring and managing environment variables and secrets for local Cloudflare Workers development using .dev.vars and .env files.

Import to Prompt Buddy

Derived skill

Files assembled from official documentation

Viewing SKILL.md

Workers Environment variables and secrets

Configuring and managing environment variables and secrets for local Cloudflare Workers development using .dev.vars and .env files.

When To Use

Use when you need to configure local environment variables, manage sensitive secrets without committing them to git, or set up environment-specific configurations for local Workers development.

Reference Files

FileContainsUse For
SKILL.mdEntry point: scope, routing table, and workflow.Start here.
docs/workers-development-testing-environment-variables-and-secrets-workflow-guide.mdDocumentation explaining how to configure environment variables and manage sensitive secrets for Cloudflare Workers using Wrangler and local files.Questions about documentation explaining how to configure environment variables and manage sensitive secrets for Cloudflare Workers u...
examples/workers-development-testing-environment-variables-and-secrets-cloudflare.textA text file demonstrating the syntax for defining environment variables and secrets such as SECRET_KEY and APITOKEN for Cloudflare Workers.Exact payloads, commands, or snippets shown in A text file demonstrating the syntax for defining environment variables and secrets such as SECRETKEY and APITOKEN fo...
examples/workers-development-testing-environment-variables-and-secrets-cloudflare-2.textA text file demonstrating the syntax for defining environment variables and secrets such as API_HOST and SECRETTOKEN for Cloudflare Workers.Exact payloads, commands, or snippets shown in A text file demonstrating the syntax for defining environment variables and secrets such as APIHOST and SECRETTOKEN f...
examples/workers-development-testing-environment-variables-and-secrets-cloudflare-3.textA text snippet demonstrating the use of the npx wrangler dev command for developing Cloudflare Workers with environment variables.Exact payloads, commands, or snippets shown in A text snippet demonstrating the use of the npx wrangler dev command for developing Cloudflare Workers with environme...
examples/workers-development-testing-environment-variables-and-secrets-cloudflare-4.textA text snippet demonstrating the wrangler dev command used to run Cloudflare Workers with environment variables during local development.Exact payloads, commands, or snippets shown in A text snippet demonstrating the wrangler dev command used to run Cloudflare Workers with environment variables durin...
examples/workers-development-testing-environment-variables-and-secrets-cloudflare-5.textA text snippet demonstrating the use of the pnpm wrangler dev command for local development with environment variables.Exact payloads, commands, or snippets shown in A text snippet demonstrating the use of the pnpm wrangler dev command for local development with environment variables.
examples/workers-development-testing-environment-variables-and-secrets-cloudflare-6.textA text snippet demonstrating the npx vite dev command used for local development of Cloudflare Workers with environment variables.Exact payloads, commands, or snippets shown in A text snippet demonstrating the npx vite dev command used for local development of Cloudflare Workers with environme...
examples/workers-development-testing-environment-variables-and-secrets-cloudflare-7.textThe terminal command used to run the local development server for Cloudflare Workers with environment variables.Exact payloads, commands, or snippets shown in The terminal command used to run the local development server for Cloudflare Workers with environment variables.
examples/workers-development-testing-environment-variables-and-secrets-cloudflare-8.textThe command used to run a local development server for Cloudflare Workers using pnpm vite dev.Exact payloads, commands, or snippets shown in The command used to run a local development server for Cloudflare Workers using pnpm vite dev.
examples/workers-development-testing-environment-variables-and-secrets-cloudflare-9.textA text file demonstrating the syntax for defining environment variables and secrets in a Cloudflare Workers configuration.Exact payloads, commands, or snippets shown in A text file demonstrating the syntax for defining environment variables and secrets in a Cloudflare Workers configura...
examples/workers-development-testing-environment-variables-and-secrets-cloudflare-10.textA command line instruction demonstrating how to use the wrangler dev command with a specific staging environment flag.Exact payloads, commands, or snippets shown in A command line instruction demonstrating how to use the wrangler dev command with a specific staging environment flag.
examples/workers-development-testing-environment-variables-and-secrets-cloudflare-11.textA command line instruction demonstrating how to use the wrangler dev command with the staging environment flag.Exact payloads, commands, or snippets shown in A command line instruction demonstrating how to use the wrangler dev command with the staging environment flag.
examples/workers-development-testing-environment-variables-and-secrets-cloudflare-12.textA command line instruction demonstrating how to use the wrangler dev command with a specific environment flag.Exact payloads, commands, or snippets shown in A command line instruction demonstrating how to use the wrangler dev command with a specific environment flag.
examples/workers-development-testing-environment-variables-and-secrets-cloudflare-13.textA command line example demonstrating how to set the CLOUDFLARE_ENV variable when running the vite development server for Workers.Exact payloads, commands, or snippets shown in A command line example demonstrating how to set the CLOUDFLAREENV variable when running the vite development server f...
examples/workers-development-testing-environment-variables-and-secrets-cloudflare-14.textA command line example demonstrating how to set the CLOUDFLARE_ENV variable when running the vite development server.Exact payloads, commands, or snippets shown in A command line example demonstrating how to set the CLOUDFLAREENV variable when running the vite development server.
examples/workers-development-testing-environment-variables-and-secrets-cloudflare-15.textA command line example demonstrating how to set the CLOUDFLARE_ENV variable to staging when running the vite development server.Exact payloads, commands, or snippets shown in A command line example demonstrating how to set the CLOUDFLAREENV variable to staging when running the vite developme...

What This Skill Covers

  • Do not use vars to store sensitive information in your Worker's Wrangler configuration file. Use secrets instead.
  • Main sections: Basic setup, Multiple local environments, Learn more.

Workflow

  1. Open the most relevant file under docs/ for the exact documented workflow and wording.
  2. Open schemas/ files for exact structured contracts.
  3. Open examples/ files for concrete requests, commands, snippets, and manifests.
  4. Do not add behavior or configuration that is not present in the attached source files.

Canonical source: https://developers.cloudflare.com/workers/development-testing/environment-variables