Wrangler to cf reference
Last updated Sep 29, 2026
cf migrate converts a Wrangler project to cf for you. It writes cloudflare.config.ts from the Wrangler configuration file, adds cf to the project, and lists the items that you finish by hand. Start with Migrate a Wrangler project, then use this page to understand what cf migrate changed or to finish a conversion by hand.
Commands
Most Wrangler commands have a cf equivalent, although the command name and arguments can differ. For example, Worker versions and deployments are under cf workers versions and cf workers deployments.
To find the cf command for a task, use any of the following:
- Search: describe the task to
cf cli search, then inspect the match withcf schema:
sh
cf cli search "create a D1 database"
cf schema d1 create
- Help: add
--helpto a command group, such ascf d1 --help, to list its commands and options. - Coding agent: ask your agent for the
cfequivalent of a Wrangler command. To set up your agent, refer to Use cf with coding agents.
Resource commands in cf take the identifiers that the Cloudflare API expects, such as a D1 database ID rather than its name. They act on remote resources. --local works only for a few resources that local development provides, such as KV keys, D1 through cf d1 raw, cf d1 migrations list, and cf d1 migrations apply, and R2 objects. For the full list, refer to Local resource data. Commands without a local equivalent, such as cf d1 query, return an error.
Commands not yet supported
cf is in beta, and some Wrangler commands are not supported yet. Run these with npx wrangler instead of installing Wrangler. Wrangler does not read cloudflare.config.ts, so pass the Worker name.
wrangler tail:cfcannot stream live logs yet. Run:
sh
npx wrangler tail <WORKER_NAME>
wrangler secret put:cfcannot set a single secret yet. Runnpx wrangler secret put <SECRET_NAME> --name <WORKER_NAME>, or upload secrets with a new Worker version by passing--secrets-file <PATH>tocf deployorcf workers versions create.
Configuration fields
cf migrate converts Wrangler fields as the following table shows. Worker settings go under worker in cloudflare.config.ts, and bindings go under worker.env. A required item is a follow-up that you resolve by hand, as described in Resolve follow-up items.
| Wrangler field | cloudflare.config.ts |
Notes |
|---|---|---|
name |
worker.name |
— |
main |
worker.entrypoint |
Written as a string path. You can replace it with a cf-worker import. |
compatibility_date |
worker.compatibilityDate |
— |
compatibility_flags |
worker.compatibilityFlags |
— |
account_id |
accountId |
Top level |
compliance_region |
complianceRegion |
Top level. fedramp_high becomes fedramp-high. |
vars |
bindings.text() or bindings.json() |
Strings use text(). Other values use json(). |
secrets.required |
bindings.secret() |
— |
| KV, D1, R2, Hyperdrive, and other bindings | The matching bindings builder |
Preview resource fields are a required item. |
services |
bindings.worker({ worker }) |
A legacy service environment is a required item. |
queues.producers |
bindings.queue({ name }) |
— |
queues.consumers |
triggers.queue({ name }) |
Consumer settings become camelCase options, such as maxBatchSize. |
Hyperdrive localConnectionString |
dev: { connectionString } on bindings.hyperdrive() |
— |
remote: true on a binding |
dev: { remote: true } |
— |
routes with zone_name |
triggers.fetch({ pattern, zone }) |
— |
routes with zone_id |
triggers.fetch({ pattern, zone }) |
Required item. zone accepts a zone name or a zone ID. |
routes with custom_domain: true |
worker.domains |
— |
triggers.crons |
triggers.scheduled({ schedule }) |
— |
durable_objects.bindings |
bindings.durableObject({ worker, exportName }) |
Required item. Review each binding. |
migrations |
worker.exports |
Not converted. Refer to Convert Durable Object migrations. |
workflows |
bindings.workflow() and exports.workflow() |
Required item. Refer to Workflows. |
containers |
defineContainer() in top-level containers |
Required item. Refer to Containers. |
assets.binding |
bindings.assets() |
— |
assets.html_handling, not_found_handling, run_worker_first |
worker.assets |
Keys become camelCase, such as notFoundHandling. |
assets.directory |
Build settings | Refer to Build settings. |
observability |
worker.observability |
Keys become camelCase, such as headSamplingRate. |
limits |
worker.limits |
Keys become camelCase, such as cpuMs. |
placement |
worker.placement |
— |
tail_consumers |
worker.tailConsumers |
— |
streaming_tail_consumers |
worker.tailConsumers |
Each entry gets streaming: true. |
workers_dev |
worker.workersDev |
— |
preview_urls |
worker.previewUrls |
— |
env.<NAME> |
A case in switch (ctx.mode) |
Refer to Convert environments to modes. |
previews |
A branch on ctx.isPreview |
Required item. Review the branch. |
site |
— | Not supported. Move the site to Workers Static Assets. |
D1 migrations_dir, migrations_pattern, migrations_table |
— | Pass --dir, --pattern, and --table to cf d1 migrations apply. |
build, minify, alias, and other build fields |
Build settings | Refer to Build settings. |
For every field and builder, refer to Programmatic configuration and the Configuration explorer.
Build settings
Build settings do not go in cloudflare.config.ts. Where they go depends on the bundler:
| Wrangler field | Vite bundler: vite.config.ts |
Wrangler bundler: wrangler.config.ts |
|---|---|---|
alias |
resolve.alias |
alias |
define |
define |
define |
minify |
build.minify |
minify |
upload_source_maps |
build.sourcemap in the Worker's Vite environment |
uploadSourceMaps |
assets.directory |
publicDir |
assetsDirectory |
build |
Run the command yourself before cf build |
build, with camelCase keys |
dev |
server options |
dev, with camelCase keys |
rules, tsconfig, no_bundle, find_additional_modules, base_dir, preserve_file_names |
Not used. Vite handles module resolution and bundling. | camelCase keys, such as noBundle and baseDir |
With the Wrangler bundler, cf migrate writes these settings to wrangler.config.ts for you and adds types: { generate: false }. With the Vite bundler, it lists the fields in a required item for you to move. wrangler.config.ts is experimental and can change during the beta.
Convert environments to modes
Wrangler environments inherit some top-level fields. cloudflare.config.ts does not merge environments. It returns one complete configuration for each mode instead. cf migrate writes a switch (ctx.mode) statement with one case for each environment. For the generated shape, refer to Environments.
Replace --env <NAME> with --mode <NAME> on project commands, such as cf dev, cf build, cf deploy, cf workers versions create, and cf workers triggers deploy.
Without --mode, the mode depends on the command and the bundler:
| Command | Vite bundler | Wrangler bundler |
|---|---|---|
cf dev |
development |
undefined |
cf build and cf deploy |
production |
undefined |
API commands, such as cf d1 list |
undefined |
undefined |
API commands evaluate cloudflare.config.ts only to read accountId and complianceRegion. If accountId depends on the mode, a Vite build and an API command can resolve different accounts. Keep accountId independent of the mode, or pass the same --mode to every command.
For more information, refer to Modes.
Convert Durable Object migrations
worker.exports replaces the ordered migrations history. cf migrate does not convert it.
On the first deployment that switches from migrations to worker.exports, declare every class whose namespace is live today. Use storage: "sqlite" or storage: "legacy-kv" to match its existing storage.
Do not copy the full migration history. Omit rename and delete operations that have already been applied. If you add them, they become stale tombstones that the deployment reports as safe to remove.
Add a tombstone only for a lifecycle change that has not been applied yet:
Select a highlighted line to show its type and description below it.
cloudflare.config.ts
Expand allCopy
import { defineConfig, exports } from "cf/config";
import * as entrypoint from "./src/index.ts" with { type: "cf-worker" };
<details>
<summary>export default defineConfig({ (defineConfig reference)</summary>
<code>defineConfig</code>Function<a href="#durable-object-tombstones-defineconfig">Link to defineConfig</a>
<code>defineConfig<T extends ConfigInput<CloudflareConfig>>(config: T): T;</code>
Defines the default export of <code>cloudflare.config.ts</code>. Pass a configuration object, a promise that resolves to one, or a function that receives the config context (<code>isPreview</code> and <code>mode</code>) and returns either.
<details>
<summary>Options (4)</summary>
<dl>
<dt><code>accountId?: string</code></dt> <dd>This is the ID of the account associated with your zone. It can also be specified through the <code>CLOUDFLARE_ACCOUNT_ID</code> environment variable.</dd>
<dt><code>complianceRegion?: "public" | "fedramp-high"</code></dt> <dd>The compliance boundary in which commands should operate. When omitted, this can be supplied through <code>CLOUDFLARE_COMPLIANCE_REGION</code>.</dd>
<dt><code>worker?: ConfigInput<WorkerConfig></code></dt> <dd>The Worker defined by this configuration.</dd>
<dt><code>containers?: ConfigInput<ContainerConfig>[]</code></dt> <dd>Container applications defined by this configuration.</dd></dl></details>
</details>
<details>
<summary>worker: { (worker reference)</summary>
<code>worker</code>Optional<a href="#durable-object-tombstones-cloudflareconfig-worker">Link to worker</a>
<code>worker?: ConfigInput<WorkerConfig></code>
The Worker defined by this configuration.
</details>
<details>
<summary>name: "orders-api", (name reference)</summary>
<code>name</code>Required<a href="#durable-object-tombstones-workerconfig-name">Link to name</a>
<code>name: string</code>
The name of your Worker.
</details>
<details>
<summary>entrypoint, (entrypoint reference)</summary>
<code>entrypoint</code>Optional<a href="#durable-object-tombstones-workerconfig-entrypoint">Link to entrypoint</a>
<code>entrypoint?: string | WorkerModule</code>
The entrypoint module that will be executed. May be either a path string (e.g. <code>"./src/index.ts"</code>) or a module namespace imported with the <code>cf-worker</code> import attribute.
</details>
<details>
<summary>compatibilityDate: "2026-08-24", (compatibilityDate reference)</summary>
<code>compatibilityDate</code>Required<a href="#durable-object-tombstones-workerconfig-compatibilitydate">Link to compatibilityDate</a>
<code>compatibilityDate: string</code>
A date in the form yyyy-mm-dd, which will be used to determine which version of the Workers runtime is used. More details at <a href="https://developers.cloudflare.com/workers/configuration/compatibility-dates">https://developers.cloudflare.com/workers/configuration/compatibility-dates</a>
</details>
<details>
<summary>exports: { (exports reference)</summary>
<code>exports</code>Optional<a href="#durable-object-tombstones-workerconfig-exports">Link to exports</a>
<code>exports?: Record<string, Export></code>
Configuration for named exports declared by the Worker. Each entry's key is the exported class name; the value configures the export. - Construct entries with <code>exports.durableObject(...)</code>. - Declares Durable Object classes exported from this Worker. For more information about Durable Objects, see the documentation at <a href="https://developers.cloudflare.com/workers/learning/using-durable-objects">https://developers.cloudflare.com/workers/learning/using-durable-objects</a>. For reference, see <a href="https://developers.cloudflare.com/workers/wrangler/configuration/#durable-objects">https://developers.cloudflare.com/workers/wrangler/configuration/#durable-objects</a>. - Construct entries with <code>exports.workflow(...)</code>. - Declares Workflows defined by this Worker. For more information about Workflows, see the documentation at <a href="https://developers.cloudflare.com/workflows/">https://developers.cloudflare.com/workflows/</a>.
