Skip to content
Esc

    Search bindings, commands, errors and guides.

    Getting started / cloudflare.config.ts

    Getting started

    Projects that use cloudflare.config.ts

    Run a Worker project that Cloudflare's cf CLI configures with cloudflare.config.ts, without a Wrangler config.

    Projects that cf init creates, or that cf migrate converts, keep their configuration in cloudflare.config.ts instead of wrangler.jsonc. Orange runs these projects as they are. It evaluates the file with the cf package that the project installs, so you keep one configuration for Cloudflare and Orange.

    Quickstart

    You need Node.js 22.18 or later, as cf does, and cf in the project’s dependencies. cf init adds it, and cf migrate adds it when its install works.

    1. Install the project's packages

      npm install
    2. Run the Worker

      Run this in the directory that holds cloudflare.config.ts.

      orange dev
    3. Deploy it

      orange deploy

    Select a mode

    cf selects a mode with --mode. Orange passes --env as the mode, as Wrangler does for cloudflare.config.ts, so a function-form config returns the config for that mode.

    orange dev --env staging

    Keep a Wrangler config next to it

    When a directory has both files, Orange runs neither on its own. Pass the one to run with --config.

    orange dev --config wrangler.jsonc
    AI context How Orange reads the file, supported fields, errors, and gaps

    Written for LLMs and coding agents: every edge case, measurement, and known deviation. You do not need it to use the feature.

    How Orange reads cloudflare.config.ts

    • Orange resolves cf from the project, then loads the @cloudflare/config package that this cf depends on. It calls Cloudflare’s own loadAndParseConfig with isPreview: false and the mode, and convertToWranglerConfig on the result. Wrangler then reads that config as it reads a wrangler.json, and Orange runs it as it runs any Wrangler config.
    • Orange does not add cf to its own dependencies. The cf release in the project decides how the file evaluates, as it does for cf dev.
    • Orange finds cloudflare.config.ts in the working directory only, as cf does for project commands. --config also takes a path to a .ts, .mts, .js, or .mjs config.
    • The project directory is the directory of cloudflare.config.ts. Orange reads .dev.vars and .dev.vars.<mode> there, as Wrangler does for cf dev.
    • --env <name> is the mode. Without --env, CLOUDFLARE_ENV is the mode, as in Wrangler. Without either, the mode is undefined, as with cf dev on the Wrangler bundler. Orange does not take --mode.
    • Modes with the same Worker name share Durable Object and D1 state, as on Cloudflare, where they deploy the same Worker.
    • orange deploy evaluates the file once on your machine, in the selected mode, bundles the Worker that it names, and writes the result into the image as cloudflare.config.orange.json. The image runs orange serve --config cloudflare.config.orange.json, so it needs no cf and no node_modules, and the image leaves cloudflare.config.ts out. The file has an openOrangeGeneratedFrom key, and with it the image ignores CLOUDFLARE_ENV, so a runner that sets it runs the same Worker. A Wrangler config of your own with that name still reads CLOUDFLARE_ENV.
    • The image leaves out what dev options set, which only cf dev reads: R2 dev.experimentalS3Credentials, Hyperdrive dev.connectionString, and access.dev. A runner reads a Hyperdrive connection string from its CLOUDFLARE_HYPERDRIVE_LOCAL_CONNECTION_STRING_<BINDING> variable, as orange serve does for any Worker, and stops at startup without one. orange deploy reads and checks no connection string on your machine. Set it on the runner pool with orange deploy --secrets-file, or with -e on a self-hosted docker run. See Hyperdrive.
    • The image also leaves out a container’s build context and build variables, because Orange builds no container image.
    • Relative paths in the file, such as a container’s Dockerfile, are from the directory of cloudflare.config.ts. A Dockerfile’s real path, after symlinks, must be inside the project, in a directory that orange deploy copies. The image names it by that path in the project.

    Supported fields

    Every field that convertToWranglerConfig writes goes through the same checks as a wrangler.jsonc. These are tested end to end:

    In cloudflare.config.tsOn Orange
    worker.name, entrypoint, compatibilityDate, compatibilityFlagsAs name, main, compatibility_date, compatibility_flags. entrypoint takes a path or a cf-worker import.
    bindings.text(), bindings.json()Variables.
    bindings.secret()A required secret, read from .dev.vars.
    bindings.kv(), bindings.d1(), bindings.r2()KV, D1, and R2 bindings. d1() works with only name.
    bindings.durableObject() and exports.durableObject({ storage })A Durable Object binding and its class, with SQLite storage. See Durable Objects.
    bindings.worker()A service binding.
    defineContainer() in containers, linked by exports.durableObject({ container })The class runs on ORANGE_SANDBOX_PROVIDER, as a Container class in a wrangler.jsonc does. Tested with @cloudflare/sandbox exec() on the default local provider. See Sandbox.
    triggers.scheduled()A cron trigger.

    Errors

    ErrorCause
    OpenOrange found both cloudflare.config.ts and wrangler.jsonc in <directory>, and does not pick one. Pass --config cloudflare.config.ts or --config wrangler.jsonc.The directory has both configs, and no --config picks one. Orange stops so that a project never switches configs, and Durable Object storage, without you choosing it.
    OpenOrange runs cloudflare.config.ts on Node.js 22.18 or later, as cf does. …Node.js is older than 22.18, which cf’s loader needs.
    OpenOrange cannot find the cf package, which <path> imports. Install it in the project …cf is not installed in the project.
    <path> threw while Orange evaluated it: <message>The config threw, such as the throw that cf migrate adds until you resolve its TODO items.
    <path> is not a valid Cloudflare configuration: and one line for each fieldcf’s schema refused a field, such as an unknown key.
    <path> defines no worker. …The default export has no worker.
    OpenOrange does not read wrangler.config.ts yet. …The project keeps build settings in wrangler.config.ts.
    Unsupported Wrangler configuration: … or Unknown Wrangler configuration fields: …A field that Orange refuses in a wrangler.jsonc too, under its Wrangler name.
    OpenOrange writes the config it evaluated to cloudflare.config.orange.json, and the project already has a file with that name. …orange deploy found a project file with the name of the file it generates.
    OpenOrange copies only the project into the image, so containers[<n>]'s Dockerfile <path> must be inside <project>. …orange deploy found a container Dockerfile whose real path is outside the project.
    OpenOrange did not copy containers[<n>]'s Dockerfile <path> into the image, …The Dockerfile is in a directory that orange deploy leaves out, such as .wrangler or node_modules.
    OpenOrange cannot delete the storage of a Durable Object class yet, so exports.<Class> cannot be "deleted". …An exports entry has state: "deleted".

    Gaps

    • wrangler.config.ts, which holds build settings such as the assets directory and the build command for projects that build with Wrangler, is not read. Orange stops with an error when it exists.
    • Static assets: cloudflare.config.ts has no assets directory. cf takes it from Vite or from wrangler.config.ts, and Orange reads neither.
    • exports.workflow() and bindings.workflow(): the pinned Wrangler 4.129.0 refuses a Workflow in exports.
    • exports.durableObject() with state: "renamed" or "transferred" stops with an error.
    • exports.durableObject({ state: "deleted" }) stops with an error, because Orange cannot delete a class’s objects yet. Remove the entry and the class’s bindings instead. Orange keeps the objects, and a class created again under that name finds them, so give a class that must start empty a new name.
    • isPreview is always false. Orange has no Worker Previews.
    • orange types stops with an error, before it evaluates the file. Run cf workers types.
    • orange migrate prepare stops with an error, before it evaluates the file. Run it with --config and the Wrangler config that cf migrate converted. orange doctor marks each Durable Object class as one that does not move.