Mar 30, 2026
2 min read

Step 4: Cloudflare local development with Doppler

Step 4: Cloudflare local development with Doppler
Develop locally without hardcoding secrets or exposing sensitive data.

Once your secrets are set up in the Doppler dashboard, ensure you’re signed in to the Doppler CLI and inside your cloned sample project folder. Then run:

This command links your project to Doppler and sets the dev environment as the default for all Doppler commands run in this directory.

Before deploying your application to production, you'll want to test locally. Cloudflare Workers present a unique challenge here. Unlike traditional Node.js applications that read secrets from process.env, Cloudflare Workers receive secrets through the env object passed to the fetch handler. This means tools like dotenv don't work out of the box.

Wrangler solves this with a .dev.vars file. During local development, Wrangler reads this file and injects the values into the env object. Instead of manually maintaining this file, you can generate it directly from Doppler by running the following command:

This command pulls all secrets from your current configuration(dev) and writes them in the format that Wrangler expects.

Now start the local development server:

You should see output indicating that Wrangler found and loaded your .dev.vars file:

Terminal screenshot showing Wrangler loading local secrets
Terminal screenshot showing Wrangler loading local secrets

Open http://localhost:8787/secrets in your browser, and you should see all secrets reporting as "configured":

Your local development environment is now pulling secrets from Doppler. Any team member with access to the Doppler project can generate the same .dev.vars file and get identical results. No more sharing secrets over Slack, no more stale .env files copied weeks ago, and no more debugging issues that turn out to be mismatched credentials.

Switching environments locally

To test with staging or production secrets locally, regenerate the .dev.vars file with a different configuration:

Now your local Worker runs with staging secrets.