Configuration (17)
Last updated Oct 20, 2026 Wrangler optionally uses a configuration file to customize the development and deployment setup for a Worker.
Note
As of Wrangler v3.91.0 Wrangler supports both JSON (wrangler.json or wrangler.jsonc) and TOML (wrangler.toml) for its configuration file. Prior to that version, only wrangler.toml was supported.
Cloudflare recommends using wrangler.jsonc for new projects, and some newer Wrangler features will only be available to projects using a JSON config file.
The format of Wrangler's configuration file is exactly the same across both languages, only the syntax differs.
You can use one of the many available online converters to easily switch between the two.
Throughout this page and the rest of Cloudflare's documentation, configuration snippets are provided as both JSON and TOML.
It is best practice to treat Wrangler's configuration file as the source of truth for configuring a Worker.
Sample Wrangler configuration
{
"$schema": "./node_modules/wrangler/config-schema.json",
// Top-level configuration
"name": "my-worker",
"main": "src/index.js",
"upload_source_maps": true,
// Set this to today's date
"compatibility_date": "2026-10-27",
"workers_dev": false,
"route": {
"pattern": "example.org/*",
"zone_name": "example.org",
},
"kv_namespaces": [
{
"binding": "<MY_NAMESPACE>",
"id": "<KV_ID>",
},
],
"env": {
"staging": {
"name": "my-worker-staging",
"route": {
"pattern": "staging.example.org/*",
"zone_name": "example.org",
},
"kv_namespaces": [
{
"binding": "<MY_NAMESPACE>",
"id": "<STAGING_KV_ID>",
},
],
},
},
}
"$schema" = "./node_modules/wrangler/config-schema.json"
name = "my-worker"
main = "src/index.js"
upload_source_maps = true
# Set this to today's date
compatibility_date = "2026-10-27"
workers_dev = false
[route]
pattern = "example.org/*"
zone_name = "example.org"
[[kv_namespaces]]
binding = "<MY_NAMESPACE>"
id = "<KV_ID>"
[env.staging]
name = "my-worker-staging"
[env.staging.route]
pattern = "staging.example.org/*"
zone_name = "example.org"
[[env.staging.kv_namespaces]]
binding = "<MY_NAMESPACE>"
id = "<STAGING_KV_ID>"
Environments
You can define different configurations for a Worker using Wrangler environments. There is a default (top-level) environment and you can create named environments that provide environment-specific configuration.
These are defined under [env.<name>] keys, such as [env.staging] which you can then preview or deploy with the -e / --env flag in the wrangler commands like npx wrangler deploy --env staging.
The majority of keys are inheritable, meaning that top-level configuration can be used in environments. Bindings, such as vars or kv_namespaces, are not inheritable and need to be defined explicitly.
Further, there are a few keys that can only appear at the top-level.
Note
If you're using the Cloudflare Vite plugin, you select the environment at dev or build time via the CLOUDFLARE_ENV environment variable rather than the --env flag. Otherwise, environments are defined in your Worker config file as usual. For more detail on using environments with the Cloudflare Vite plugin, refer to the plugin documentation.
Automatic provisioning
Wrangler can automatically provision resources for you when you deploy your Worker without you having to create them ahead of time.
This currently works for the following resources: KV, R2, D1, Flagship, AI Search, Agent Memory, Dispatch Namespaces and Queues.
To use this feature, add bindings to your configuration file without adding resource IDs, or in the case of R2, a bucket name. Resources will be created with the name of your worker as the prefix.
{
"kv_namespaces": [
{
"binding": "<MY_KV_NAMESPACE>",
},
],
}
[[kv_namespaces]]
binding = "<MY_KV_NAMESPACE>"
When you run wrangler dev, local resources will automatically be created which persist between runs. When you run wrangler deploy, resources will be created for you, and their IDs will be written back to your configuration file.
If you deploy a worker with resources and no resource IDs from the dashboard (for example, via GitHub), resources will be created, but their IDs will only be accessible via the dashboard. Currently, these resource IDs will not be written back to your repository.
Top-level only keys
Top-level keys apply to the Worker as a whole (and therefore all environments). They cannot be defined within named environments.
keep_varsbooleanoptional- Whether Wrangler should keep variables configured in the dashboard on deploy. Refer to source of truth.
addressesstring[]optional- A list of inbound email addresses that Email Routing routes to this Worker. Each entry is either a literal recipient address (for example,
support@example.com) or a*@domaincatch-all (for example,*@example.com). Catch-all entries support apex domains only. When you deploy the Worker or its triggers, Wrangler reconciles the Worker's managed Email Routing rules with this list. send_metricsbooleanoptional- Whether Wrangler should send usage data to Cloudflare for this project. Defaults to
true. You can learn more about this in our data policy ↗︎. dependencies_instrumentationobjectoptional- Configures npm package dependency instrumentation when deploying or uploading a Worker version. Defaults to enabled.
enabledboolean— Whether Wrangler should collect and send npm package dependency metadata (package names and versions). Defaults totrue.siteobjectoptional deprecated- See the Workers Sites section below for more information. Cloudflare Pages and Workers Assets is preferred over this approach.
- This is not supported by the Cloudflare Vite plugin.
Inheritable keys
Inheritable keys are configurable at the top-level, and can be inherited (or overridden) by environment-specific configuration.
Note
At a minimum, the name, main and compatibility_date keys are required to deploy a Worker.
The main key is optional for assets-only Workers.
namestringrequired- The name of your Worker. Alphanumeric characters (
a,b,c, etc.) and dashes (-) only. Do not use underscores (_). Worker names can be up to 255 characters. If you plan to use aworkers.devsubdomain, the name must be 63 characters or less and cannot start or end with a dash. mainstringrequired- The path to the entrypoint of your Worker that will be executed. For example:
./src/index.ts. compatibility_datestringrequired- A date in the form
yyyy-mm-dd, which will be used to determine which version of the Workers runtime is used. Refer to Compatibility dates. account_idstringoptional- This is the ID of the account associated with your zone. You might have more than one account, so make sure to use the ID of the account associated with the zone/route you provide, if you provide one. It can also be specified through the
CLOUDFLARE_ACCOUNT_IDenvironment variable. compatibility_flagsstring[]optional- A list of flags that enable features from upcoming features of the Workers runtime, usually used together with
compatibility_date. Refer to compatibility dates. workers_devbooleanoptional- Enables use of
*.workers.devsubdomain to deploy your Worker. If you have a Worker that is only forscheduledevents, you can set this tofalse. Defaults totruewhen the configuration has norouteorroutes, andfalseotherwise. Refer to types of routes. preview_urlsbooleanoptional- Enables Version URLs and
workers.devPreview URLs. If omitted, Wrangler does not change an existing setting. If no setting exists, its initial value depends onworkers_dev. Refer to Version URLs and Previews. routeRouteoptional- A route that your Worker should be deployed to. Only one of
routesorrouteis required. Refer to types of routes. routesRoute[]optional- An array of routes that your Worker should be deployed to. Only one of
routesorrouteis required. Refer to types of routes. tsconfigstringoptional- Path to a custom
tsconfig. - Not applicable if you're using the Cloudflare Vite plugin.
triggersobjectoptional- Cron definitions to trigger a Worker's
scheduledfunction. Refer to triggers. rulesRuleoptional- An ordered list of rules that define which modules to import, and what type to import them as. You will need to specify rules to use
Text,DataandCompiledWasmmodules, or when you wish to have a.jsfile be treated as anESModuleinstead ofCommonJS. - Not applicable if you're using the Cloudflare Vite plugin.
buildBuildoptional- Configures a custom build step to be run by Wrangler when building your Worker. Refer to Custom builds.
- Not applicable if you're using the Cloudflare Vite plugin.
no_bundlebooleanoptional- Skip internal build steps and directly deploy your Worker script. You must have a plain JavaScript Worker with no dependencies.
- Not applicable if you're using the Cloudflare Vite plugin.
find_additional_modulesbooleanoptional- If true then Wrangler will traverse the file tree below
base_dir. Any files that matchruleswill be included in the deployed Worker. Defaults to true ifno_bundleis true, otherwise false. Can only be used with Module format Workers (not Service Worker format). - Not applicable if you're using the Cloudflare Vite plugin.
base_dirstringoptional- The directory in which module "rules" should be evaluated when including additional files (via
find_additional_modules) into a Worker deployment. Defaults to the directory containing themainentry point of the Worker if not specified. - Not applicable if you're using the Cloudflare Vite plugin.
preserve_file_namesbooleanoptional- Determines whether Wrangler will preserve the file names of additional modules bundled with the Worker. The default is to prepend filenames with a content hash. For example,
34de60b44167af5c5a709e62a4e20c4f18c9e3b6-favicon.ico. - Not applicable if you're using the Cloudflare Vite plugin.
minifybooleanoptional- Minify the Worker script before uploading.
- If you're using the Cloudflare Vite plugin,
minifyis replaced by Vite'sbuild.minify↗︎. keep_namesbooleanoptional- Wrangler uses esbuild to process the Worker code for development and deployment. This option allows you to specify whether esbuild should apply its keepNames ↗︎ logic to the code or not. Defaults to
true. logpushbooleanoptional- Enables Workers Trace Events Logpush for a Worker. Any scripts with this property will automatically get picked up by the Workers Logpush job configured for your account. Defaults to
false. Refer to Workers Logpush. limitsLimitsoptional-
Configures limits to be imposed on execution at runtime. Refer to Limits.
-
observabilityobjectoptional - Configures automatic observability settings for telemetry data emitted from your Worker. Refer to Observability.
assetsAssetsoptional- Configures static assets that will be served. Refer to Assets for more details.
exportsobjectoptional- Declares the Durable Object classes this Worker exports and their lifecycle state (
created,deleted,renamed,transferred,expecting-transfer). Refer to Durable Object class exports. Durable Object entries are mutually exclusive withmigrations. - Declares the Workflows this Worker defines. Refer to Workflow exports.
migrationsobjectoptional- Legacy imperative configuration that maps a Durable Object from a class name to a runtime state. For new Workers, prefer
exports. Refer to Durable Object class migrations (legacy). placementobjectoptional- Configures where your Worker runs to minimize latency to back-end services. Refer to Placement.
modestring— Set to"smart"to automatically place your Worker near back-end services based on observed latency.regionstring— Specify a cloud region (for example,"aws:us-east-1","gcp:europe-west1", or"azure:westeurope") to place your Worker near infrastructure in that region.hoststring— Specify a hostname and port for a single-homed layer 4 service (for example,"my_database_host.com:5432") to place your Worker near that service.hostnamestring— Specify a hostname for a single-homed layer 7 service (for example,"my_api_server.com") to place your Worker near that service.
Non-inheritable keys
Non-inheritable keys are configurable at the top-level, but cannot be inherited by environments and must be specified for each environment.
