Loading source
Pulling the file list, source metadata, and syntax-aware rendering for this listing.
Source from repo
Comprehensive Cloudflare platform skill covering Workers, D1, R2, KV, AI, Durable Objects, and security.
Files
Skill
Size
Entrypoint
Format
Open file
Syntax-highlighted preview of this file as included in the skill package.
references/wrangler/configuration.md
1# Wrangler Configuration23Configuration reference for wrangler.jsonc (recommended).45## Config Format67**wrangler.jsonc recommended** (Wrangler v4+) - provides schema validation.89```jsonc10{11"$schema": "./node_modules/wrangler/config-schema.json",12"name": "my-worker",13"main": "src/index.ts",14"compatibility_date": "2025-01-01", // Use current date15"vars": { "API_KEY": "dev-key" },16"kv_namespaces": [{ "binding": "MY_KV", "id": "abc123" }]17}18```1920## Field Inheritance2122Inheritable: `name`, `main`, `compatibility_date`, `routes`, `triggers`23Non-inheritable (define per env): `vars`, bindings (KV, D1, R2, etc.)2425## Environments2627```jsonc28{29"name": "my-worker",30"vars": { "ENV": "dev" },31"env": {32"production": {33"name": "my-worker-prod",34"vars": { "ENV": "prod" },35"route": { "pattern": "example.com/*", "zone_name": "example.com" }36}37}38}39```4041Deploy: `wrangler deploy --env production`4243## Routing4445```jsonc46// Custom domain (recommended)47{ "routes": [{ "pattern": "api.example.com", "custom_domain": true }] }4849// Zone-based50{ "routes": [{ "pattern": "api.example.com/*", "zone_name": "example.com" }] }5152// workers.dev53{ "workers_dev": true }54```5556## Bindings5758```jsonc59// Variables60{ "vars": { "API_URL": "https://api.example.com" } }6162// KV63{ "kv_namespaces": [{ "binding": "CACHE", "id": "abc123" }] }6465// D166{ "d1_databases": [{ "binding": "DB", "database_id": "abc-123" }] }6768// R269{ "r2_buckets": [{ "binding": "ASSETS", "bucket_name": "my-assets" }] }7071// Durable Objects72{ "durable_objects": {73"bindings": [{74"name": "COUNTER",75"class_name": "Counter",76"script_name": "my-worker" // Required for external DOs77}]78} }79{ "migrations": [{ "tag": "v1", "new_sqlite_classes": ["Counter"] }] }8081// Service Bindings82{ "services": [{ "binding": "AUTH", "service": "auth-worker" }] }8384// Queues85{ "queues": {86"producers": [{ "binding": "TASKS", "queue": "task-queue" }],87"consumers": [{ "queue": "task-queue", "max_batch_size": 10 }]88} }8990// Vectorize91{ "vectorize": [{ "binding": "VECTORS", "index_name": "embeddings" }] }9293// Hyperdrive (requires nodejs_compat for pg/postgres)94{ "hyperdrive": [{ "binding": "HYPERDRIVE", "id": "hyper-id" }] }95{ "compatibility_flags": ["nodejs_compat"] } // For pg/postgres9697// Workers AI98{ "ai": { "binding": "AI" } }99100// Workflows101{ "workflows": [{ "binding": "WORKFLOW", "name": "my-workflow", "class_name": "MyWorkflow" }] }102103// Secrets Store (centralized secrets)104{ "secrets_store": [{ "binding": "SECRETS", "id": "store-id" }] }105106// Constellation (AI inference)107{ "constellation": [{ "binding": "MODEL", "project_id": "proj-id" }] }108```109110## Workers Assets (Static Files)111112Recommended for serving static files (replaces old `site` config).113114```jsonc115{116"assets": {117"directory": "./public",118"binding": "ASSETS",119"html_handling": "auto-trailing-slash", // or "none", "force-trailing-slash"120"not_found_handling": "single-page-application" // or "404-page", "none"121}122}123```124125Access in Worker:126```typescript127export default {128async fetch(request, env) {129// Try serving static asset first130const asset = await env.ASSETS.fetch(request);131if (asset.status !== 404) return asset;132133// Custom logic for non-assets134return new Response("API response");135}136}137```138139## Placement140141Control where Workers run geographically.142143```jsonc144{145"placement": {146"mode": "smart" // or "off"147}148}149```150151- `"smart"`: Run Worker near data sources (D1, Durable Objects) to reduce latency152- `"off"`: Default distribution (run everywhere)153154## Auto-Provisioning (Beta)155156Omit resource IDs - Wrangler creates them and writes back to config on deploy.157158```jsonc159{ "kv_namespaces": [{ "binding": "MY_KV" }] } // No id - auto-provisioned160```161162After deploy, ID is added to config automatically.163164## Advanced165166```jsonc167// Cron Triggers168{ "triggers": { "crons": ["0 0 * * *"] } }169170// Observability (tracing)171{ "observability": { "enabled": true, "head_sampling_rate": 0.1 } }172173// Runtime Limits174{ "limits": { "cpu_ms": 100 } }175176// Browser Rendering177{ "browser": { "binding": "BROWSER" } }178179// mTLS Certificates180{ "mtls_certificates": [{ "binding": "CERT", "certificate_id": "cert-uuid" }] }181182// Logpush (stream logs to R2/S3)183{ "logpush": true }184185// Tail Consumers (process logs with another Worker)186{ "tail_consumers": [{ "service": "log-worker" }] }187188// Unsafe bindings (access to arbitrary bindings)189{ "unsafe": { "bindings": [{ "name": "MY_BINDING", "type": "plain_text", "text": "value" }] } }190```191192## See Also193194- [README.md](./README.md) - Overview and commands195- [api.md](./api.md) - Programmatic API196- [patterns.md](./patterns.md) - Workflows197- [gotchas.md](./gotchas.md) - Common issues198