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

推荐订阅源

D
DataBreaches.Net
S
Schneier on Security
T
The Exploit Database - CXSecurity.com
Webroot Blog
Webroot Blog
AI
AI
P
Palo Alto Networks Blog
Attack and Defense Labs
Attack and Defense Labs
WordPress大学
WordPress大学
月光博客
月光博客
阮一峰的网络日志
阮一峰的网络日志
Spread Privacy
Spread Privacy
T
Tor Project blog
罗磊的独立博客
小众软件
小众软件
S
Security Affairs
酷 壳 – CoolShell
酷 壳 – CoolShell
量子位
Apple Machine Learning Research
Apple Machine Learning Research
T
Threatpost
NISL@THU
NISL@THU
博客园_首页
PCI Perspectives
PCI Perspectives
大猫的无限游戏
大猫的无限游戏
IT之家
IT之家
N
News and Events Feed by Topic
freeCodeCamp Programming Tutorials: Python, JavaScript, Git & More
Forbes - Security
Forbes - Security
博客园 - 叶小钗
D
Darknet – Hacking Tools, Hacker News & Cyber Security
OSCHINA 社区最新新闻
OSCHINA 社区最新新闻
Last Week in AI
Last Week in AI
L
LINUX DO - 热门话题
T
Threat Research - Cisco Blogs
cs.AI updates on arXiv.org
cs.AI updates on arXiv.org
腾讯CDC
Security Latest
Security Latest
Exploit-DB.com RSS Feed
Exploit-DB.com RSS Feed
The Cloudflare Blog
A
About on SuperTechFans
爱范儿
爱范儿
Threat Intelligence Blog | Flashpoint
Threat Intelligence Blog | Flashpoint
TaoSecurity Blog
TaoSecurity Blog
宝玉的分享
宝玉的分享
G
GRAHAM CLULEY
雷峰网
雷峰网
F
Full Disclosure
I
Intezer
Cloudbric
Cloudbric
博客园 - 三生石上(FineUI控件)
U
Unit 42

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: