Workers CLI: Wrangler Migration, Typed Configuration, and Deploy
How the Cloudflare CLI (cf) replaces or complements Wrangler: install, cloudflare.config.ts, migrate, dev, build, deploy, and verification.
This page summarizes Cloudflare documentation on the Cloudflare CLI (cf), a beta command-line interface for the public Cloudflare API and for Workers projects. If you already use Wrangler with wrangler.jsonc or wrangler.toml, most Worker concepts carry over; the main shift is typed project configuration in cloudflare.config.ts and optional migration with cf migrate.
The Cloudflare CLI, cf, is now in beta. cf is one command-line interface for the public Cloudflare API and for Workers projects. Use it to manage zones, DNS, storage, and security settings, and to create, develop, and deploy Workers, without switching between tools.
— Cloudflare, Cloudflare CLI is now in beta
cf is in beta: commands, configuration, and Build Output can change before a stable release.
cf CLI vs Wrangler: when to use which tool
Section titled “cf CLI vs Wrangler: when to use which tool”cf is one interface for account-wide API tasks and for Workers projects that use cloudflare.config.ts. Wrangler remains the CLI for projects configured only with wrangler.jsonc or wrangler.toml.
| Area | Wrangler | cf |
|---|---|---|
| Coverage | Workers and a subset of Cloudflare products | The public Cloudflare API (more than 2,900 commands) |
| Sign-in | wrangler login |
cf auth login (separate credentials) |
| Project configuration | wrangler.jsonc or wrangler.toml |
cloudflare.config.ts (TypeScript) |
| Environments | env blocks with --env |
Modes with --mode |
| Build | Wrangler’s bundler or the Cloudflare Vite plugin | Same options, selected per project |
| Deployable artifact | Internal to Wrangler | Build Output in .cloudflare/output/v0/ |
If you build with Wrangler, most of what you know carries over to cf. This page explains what changes, how to use cf next to an existing Wrangler project, and when to migrate the project itself.
— Cloudflare, cf for Wrangler users
You can run resource commands (cf d1 list, cf r2 buckets list, and similar) in any directory, including an unmigrated Wrangler project, without migrating. Those commands do not read the Wrangler file; set CLOUDFLARE_ACCOUNT_ID or choose an account when prompted. Keep using wrangler dev and wrangler deploy until you migrate. In automation, both tools read CLOUDFLARE_API_TOKEN and CLOUDFLARE_ACCOUNT_ID.
Common conclusion: use Wrangler for day-to-day deploy on legacy config; use cf for DNS, D1, R2, and other API work immediately, and for full project workflow after cf migrate.
What still requires Wrangler after you migrate
Section titled “What still requires Wrangler after you migrate”cf is in beta and does not yet cover every Wrangler task:
Live logs: cf cannot stream live logs yet. Run
npx wrangler tail <WORKER_NAME>instead of installing Wrangler. Single secrets: cf cannot set a single secret yet.— Cloudflare, cf for Wrangler users
Wrangler does not read cloudflare.config.ts. If you still run Wrangler commands in a migrated project, keep the Wrangler configuration file until you no longer need those commands.
Install cf and sign in: first commands
Section titled “Install cf and sign in: first commands”Install cf globally so the command is available in every directory:
npm install --global cfThe package also installs cloudflare as an alias if another cf is already on your PATH. Confirm installation with cf --version, then sign in:
cf auth logincf prints a link and a one-time code, and opens the link in your browser. Approve the request to give cf access to your Cloudflare account.
— Cloudflare, Get started
cf keeps its own credentials and does not reuse a Wrangler login. On a headless machine, use cf auth login --no-browser. Projects created with cf init pin cf as a development dependency so collaborators and CI run the same version; loading cloudflare.config.ts requires Node.js 22.18 or later (Bun cannot load that file in-project).
cloudflare.config.ts: typed Workers configuration
Section titled “cloudflare.config.ts: typed Workers configuration”cloudflare.config.ts is the typed configuration file for a Workers project. Its default export can define a Worker, Container applications, and account settings.
cloudflare.config.ts is the typed configuration file for a Workers project. Its default export can define a Worker, Container applications, and account settings. Because the file is a TypeScript module, it can use imports, functions, environment variables, and asynchronous values.
— Cloudflare, Programmatic configuration
Set "type": "module" in package.json. Import helpers from cf/config and use defineConfig() for the default export. A Worker that runs code needs at minimum worker.name, worker.compatibilityDate, and worker.entrypoint. The recommended entrypoint form imports the module with the cf-worker import attribute so editors infer binding and export types:
import { bindings, defineConfig } from "cf/config";import * as entrypoint from "./src/index.ts" with { type: "cf-worker" };
export default defineConfig({ worker: { name: "my-worker", compatibilityDate: "2026-08-24", entrypoint, env: { WORLD: bindings.text("World"), }, },});Bindings live under worker.env (bindings.d1(), bindings.queue(), bindings.secret(), and others). Triggers (triggers.fetch(), triggers.scheduled(), triggers.queue(), and more) go in worker.triggers. Exports (exports.durableObject(), exports.workflow()) declare platform lifecycle for classes; bindings inject resources on env. The Configuration explorer documents every field.
Modes: replacing Wrangler --env
Section titled “Modes: replacing Wrangler --env”Pass --mode (or -m) so a function-form config returns different values:
cf dev --mode stagingcf build --mode stagingcf deploy --mode stagingReturn one complete configuration for each mode. Programmatic configuration does not merge environment blocks the way Wrangler environments do. A mode deploys a separate Worker only when it returns a different name.
— Cloudflare, Develop, build, and deploy
When you omit --mode, the Cloudflare Vite plugin uses development for cf dev and production for cf build and cf deploy. Build Output records the mode; prebuilt deploys must pass the same mode.
cf dev, cf build, and cf deploy: how the CLI runs your project
Section titled “cf dev, cf build, and cf deploy: how the CLI runs your project”cf does not run a dev server or bundler itself. For cf dev, cf build, and every other command that builds first, cf hands the work to one of these tools: The framework’s own command … An installed Cloudflare build tool … the Cloudflare Vite plugin, or Wrangler 4.136.0 or later.
— Cloudflare, Develop, build, and deploy
Builds write Build Output to .cloudflare/output/v0/. cf does not run your package.json scripts; if you need tsc -b before Vite, chain it yourself (tsc -b && cf build). When cf forwards to a framework command (for example npx vite), it forwards only --mode—set ports and other flags in vite.config.ts or run Vite directly.
New projects start with:
cf init my-workercf init creates cloudflare.config.ts, vite.config.ts with @cloudflare/vite-plugin@beta, and scripts that call cf dev, cf build, and cf deploy. For CI, pass --package-manager and optionally --no-install as described in Deploy your first Worker.
cf migrate: move from wrangler.jsonc to cloudflare.config.ts
Section titled “cf migrate: move from wrangler.jsonc to cloudflare.config.ts”Migrate when you want TypeScript configuration with inferred binding types, one CLI for project and account tasks, or build-once deploy-later workflows from CI.
- Commit or stash changes; install dependencies (Wrangler bundler path needs Wrangler 4.136.0+).
- Preview:
cf migrate --dry-run(optionally--bundler viteor--bundler wrangler). - Run:
cf migratein the directory with exactly one Wrangler config (or pass the file path). - Resolve every
[required]follow-up and removeTODO(@cloudflare)comments plus the top-levelthrowincloudflare.config.ts. - Update scripts to
cf dev/cf build/cf deploy, add.cloudflare/to.gitignore, and deploy withcf deploy.
cf migrate writes cloudflare.config.ts beside the Wrangler file, adds cf as a dev dependency, and optionally creates wrangler.config.ts for Wrangler-bundler build settings. It never overwrites an existing cloudflare.config.ts. Durable Object migrations history is not converted; replace with worker.exports declarations (Wrangler to cf reference). Wrangler env blocks become switch (ctx.mode) cases—use --mode instead of --env.
Find commands and documentation from the terminal
Section titled “Find commands and documentation from the terminal”With more than 2,900 API-backed commands, discovery tools matter:
| Task | Command | Credentials |
|---|---|---|
| Find a command | cf cli search "create D1 database" |
Not required (local) |
| Inspect API shape | cf schema d1 create |
Not required for schema |
| Search docs | cf docs search "proxy a DNS record" |
Internet only; no login |
Cloudflare CLI 1.0.0-beta.16 includes cf docs search, so you and your coding agent can find Cloudflare documentation without leaving the terminal.
— Cloudflare, Search Cloudflare documentation with the Cloudflare CLI
cf docs search returns up to five JSON results with title, description, and url. Fetch a page as Markdown with curl -H "Accept: text/markdown" "<url>". Command names use kebab-case in recent releases (for example cf accounts billing get-credits).
For coding agents, Cloudflare documents setup in Use cf with coding agents: prefer cf unless the repo still has only a Wrangler configuration file; use cf cli search and cf docs search without putting secrets in queries; preview destructive work with --dry-run.
cf in CI: pinning and non-interactive behavior
Section titled “cf in CI: pinning and non-interactive behavior”Pin cf as a dev dependency and run npx cf <command> so CI matches local versions (Use cf in CI). Non-interactive runs use default answers for prompts, abort destructive commands without --force (exit 0 with Aborted. on stderr), and require explicit flags for cf init directory choice. Disable telemetry with CF_SEND_TELEMETRY=false or DO_NOT_TRACK=1.
Artifact-based pipelines can use @cloudflare/ci runners with cache inputs on lockfiles, then wrangler deploy or cf deploy with CLOUDFLARE_API_TOKEN—see Build and deploy on push for the workflow pattern.
Common mistakes and how to avoid them
Section titled “Common mistakes and how to avoid them”- Running
cf buildin an unmigrated Wrangler repo — can corrupt config; runcf migratefirst or undo auto-generated files per cf for Wrangler users. - Expecting
cfto run yourpackage.jsonscripts — chain custom steps beforecf build(Develop, build, and deploy). - Deploying prebuilt output with the wrong mode — rebuild or pass the mode recorded in
.cloudflare/output/v0/config.json. - Using D1 database names with
cf d1 query—cfexpects API IDs; Wrangler often accepts names (cf for Wrangler users). - Leaving migration
throwincloudflare.config.ts—cf dev,cf build, andcf deployfail until TODOs are resolved (Migrate a Wrangler project). - Trusting exit code 0 on destructive commands in CI — without
--force, deletes abort with status 0; read stderr (Use cf with coding agents).
How to check this on your site
Section titled “How to check this on your site”- Run
cf --versionandcf auth whoamiafter install and sign-in to confirm the CLI and account. - In a
cfproject, runcf buildand confirm.cloudflare/output/v0/config.jsonexists (Develop, build, and deploy). - Run
cf cli search "<your task>"andcf schema <command>to verify command discovery (Manage resources from the command line). - Before migrating production, run
cf migrate --dry-runand review required follow-ups (Migrate a Wrangler project). - You can check automatically in Answerwell (our tool): https://answerwell.org/workspace
Report an error or ask a question
Section titled “Report an error or ask a question”If something on this page is wrong or unclear, email yimasynthetic@gmail.com with the page URL and the exact statement you are asking about.