惯性聚合 高效追踪和阅读你感兴趣的博客、新闻、科技资讯
阅读原文 在惯性聚合中打开

推荐订阅源

人人都是产品经理
人人都是产品经理
D
Docker
GbyAI
GbyAI
B
Blog RSS Feed
博客园 - 司徒正美
博客园 - Franky
美团技术团队
Cyber Security Advisories - MS-ISAC
Cyber Security Advisories - MS-ISAC
aimingoo的专栏
aimingoo的专栏
C
Check Point Blog
IT之家
IT之家
让小产品的独立变现更简单 - ezindie.com
让小产品的独立变现更简单 - ezindie.com
www.infosecurity-magazine.com
www.infosecurity-magazine.com
AI
AI
O
OpenAI News
Attack and Defense Labs
Attack and Defense Labs
cs.CV updates on arXiv.org
cs.CV updates on arXiv.org
T
Tailwind CSS Blog
酷 壳 – CoolShell
酷 壳 – CoolShell
S
Secure Thoughts
博客园 - 聂微东
L
LINUX DO - 最新话题
U
Unit 42
SecWiki News
SecWiki News
A
Arctic Wolf
Schneier on Security
Schneier on Security
Threat Intelligence Blog | Flashpoint
Threat Intelligence Blog | Flashpoint
V
Visual Studio Blog
量子位
The Cloudflare Blog
cs.AI updates on arXiv.org
cs.AI updates on arXiv.org
大猫的无限游戏
大猫的无限游戏
Google DeepMind News
Google DeepMind News
G
Google Developers Blog
T
Threat Research - Cisco Blogs
TaoSecurity Blog
TaoSecurity Blog
Recent Commits to openclaw:main
Recent Commits to openclaw:main
B
Blog
博客园 - 【当耐特】
C
CERT Recently Published Vulnerability Notes
Scott Helme
Scott Helme
Last Week in AI
Last Week in AI
D
Darknet – Hacking Tools, Hacker News & Cyber Security
Microsoft Security Blog
Microsoft Security Blog
Apple Machine Learning Research
Apple Machine Learning Research
F
Full Disclosure
Hacker News: Ask HN
Hacker News: Ask HN
A
About on SuperTechFans
博客园 - 三生石上(FineUI控件)
Latest news
Latest news

Flavio Copes

Workers Cache: a cache in front of your Cloudflare Worker Cloudflare Drop: drag a folder, get a live site Temporary Cloudflare accounts: agents can now deploy without signing up Moondream 3.1 on Workers AI: fast vision at the edge inferencecost.dev: what will AI inference cost you at 10k users? Sitebase: all the features your website needs, in one place StackPlan: figure out where to deploy your app, and what it How the Cloudflare Pages build cache works The Summer of Code How I generate an Open Graph image for every post New: 90 free tools for developers How I added search to my static site with Pagefind How to rebuild a Cloudflare site on a schedule Cloudflare Email Workers: run code when an email arrives Cloudflare Turnstile: stop bots without annoying CAPTCHAs Cloudflare Workers: secrets and environments Cloudflare Workers observability: logs and traces Cloudflare Analytics Engine: store and query metrics The AI Workshop (July 2026 cohort) Cloudflare Cron Triggers: run a Worker on a schedule Cloudflare Durable Objects: state that lives in one place Cloudflare Queues: run work in the background Cloudflare R2: object storage without egress fees Cloudflare KV: a key-value store for your Workers Cloudflare D1: a SQL database for your Workers Serving a website with Cloudflare Workers static assets Executor: one gateway to connect your AI agent to every tool Cloudflare Workers: your first serverless function Vercel eve: an open framework for building AI agents Flue: the open framework for building AI agents Val Town: write and deploy code in seconds A hands-on guide to The Agency, a collection of AI agents The AI Workshop (June 2026 cohort) The AI Workshop (May 2026 cohort) The AI Workshop (Apr 2026 cohort)
Wrangler: the Cloudflare Workers command line tool
Flavio Copes · 2026-06-21 · via Flavio Copes

By Flavio Copes

A practical guide to Wrangler, the CLI you use to build, run, deploy, and manage Cloudflare Workers and everything attached to them.

~~~

If you build on Cloudflare Workers, you’ll spend a lot of time with Wrangler.

Wrangler is the command line tool for Workers. You use it to run your code locally, deploy it, manage your databases and storage, read logs, and handle secrets. Think of it as your remote control for the whole platform.

It comes installed in any project you scaffold with npm create cloudflare, so you usually run it with npx wrangler.

Let’s go through the commands I use every day.

The config file

Everything Wrangler does is driven by a config file in your project, wrangler.jsonc (older projects use wrangler.toml).

A minimal one looks like this:

{
  "name": "my-worker",
  "main": "src/index.ts",
  "compatibility_date": "2026-06-20"
}

name is your Worker’s name. main points to your code. compatibility_date pins the runtime behavior to a date, so your Worker keeps working the same way even as Cloudflare updates things.

This file is also where you attach databases, storage, and other resources. We’ll add to it throughout the series.

Run locally

npx wrangler dev

This runs your Worker on your machine, using the same engine Cloudflare uses in production. You get a local URL and live reload on save.

Deploy

npx wrangler deploy

This uploads your Worker and makes it live. The first time, it opens your browser to log in.

Watch the logs

When something misbehaves in production, you want to see what’s happening. Stream live logs from your deployed Worker:

npx wrangler tail

Every request and console.log shows up in your terminal as it happens.

Manage secrets

Don’t put API keys in your code. Store them as secrets:

npx wrangler secret put STRIPE_KEY

It prompts you for the value, encrypts it, and makes it available on env.STRIPE_KEY in your Worker. The value never lives in your repo.

Manage your resources

Wrangler also creates and manages the things you attach to a Worker. For example, to create a database:

npx wrangler d1 create my-database

Or apply database migrations:

npx wrangler d1 migrations apply my-database --local

There are similar commands for KV, R2, and Queues. Each gets its own post in this series.

Generate types

If you use TypeScript, this command reads your config and generates types for all your bindings:

npx wrangler types

Now env.DB, env.UPLOADS, and the rest are fully typed. I run this whenever I change my config.

Environments

Real apps have more than one environment: production, staging, maybe a beta. Wrangler handles this with named environments in your config:

{
  "name": "my-worker",
  "env": {
    "staging": {
      "name": "my-worker-staging"
    },
    "production": {
      "name": "my-worker-prod"
    }
  }
}

Then you deploy a specific one:

npx wrangler deploy --env production

Each environment can have its own database, its own secrets, its own domain. I’ll come back to environments in a later post, because there are a couple of gotchas worth knowing.

The pattern to remember

Once you know Wrangler, the workflow for any Cloudflare feature is the same: add it to wrangler.jsonc, create it with a wrangler command, then use it through env in your code.

That consistency is the thing I like most. The full command reference is in the Wrangler docs.

~~~

Related posts about cloudflare: