wrangler experimental TypeScript config via --x-new-config
Introduced 2026-06-11 · score 0.95
HOW TO USE IT
When authoring a Worker config in TypeScript, add the required `cloudflare.config.ts` using `defineWorker` from `wrangler/experimental-config`, then run a supported Wrangler command with `--x-new-config`. Optionally add `wrangler.config.ts` using `defineWranglerConfig`; branch on `ctx.mode` in either file’s function form for per-environment settings.
wrangler dev --x-new-configwrangler build --x-new-configimport { defineWorker, bindings } from "wrangler/experimental-config";
import * as entrypoint from "./src/index.ts" with { type: "cf-worker" };
export default defineWorker((ctx) => ({
name: "<worker-name>",
entrypoint,
compatibilityDate: "<YYYY-MM-DD>",
env: {
MY_KV: bindings.kv(),
MY_TEXT: bindings.text(`The mode is ${ctx.mode}`),
},
}));WHY THIS HELPS
When authoring a Worker configuration in TypeScript, run Wrangler commands using the experimental config files.
REQUIREMENTS AND LIMITATIONS
- Version: 4.100.0
- Availability: Experimental, opt-in; the flag, config formats, and `wrangler/experimental-config` exports may change in any release.
- --x-new-config (required): Opt into loading Worker configuration from `cloudflare.config.ts` for the supported commands.
- cloudflare.config.ts (required): Worker runtime configuration, authored with `defineWorker` from `wrangler/experimental-config`.
- wrangler.config.ts: Wrangler-specific development/build configuration, authored with `defineWranglerConfig` from `wrangler/experimental-config`.
- ctx.mode: Use within the function form of either config file to branch configuration by environment mode.
- Prerequisite: Wrangler 4.100.0 introduced the experimental opt-in; flag and config exports may change in any release.
- Prerequisite: Provide `cloudflare.config.ts`; `wrangler.config.ts` is optional.
- `cloudflare.config.ts` is required.
- `wrangler.config.ts` is optional.
- Per-environment configuration uses `ctx.mode` branching inside the function form of either file.
FIRST-PARTY EVIDENCE
Check the installed version and the source before using it. Entry JSON