Workflows can finally be declared right in exports!
Hi there, it's Shii-chan! Today I found a small but genuinely handy update to Cloudflare Workflows, and I want to share it with you!
Cloudflare ChangelogWhat was announced?
According to the Cloudflare Changelog, you can now declare a Workflow that a Worker defines directly in the exports field of your Wrangler configuration file.
Until now, the only way for a Worker to define a Workflow was through a workflows binding — even when the Worker never actually called that Workflow itself.
In JSON config, you key each entry by the name of the class that extends WorkflowEntrypoint, like this:
{
"exports": {
"MyWorkflow": {
"type": "workflow",
"name": "my-workflow",
"limits": { "steps": 25000 },
"schedules": ["0 * * * *"]
}
}
}
Or in TOML:
[exports.MyWorkflow]
type = "workflow"
name = "my-workflow"
schedules = ["0 * * * *"]
[exports.MyWorkflow.limits]
steps = 25_000
The story so far
Before this, even a Workflow that a Worker never invoked itself still needed a workflows binding just to get registered. A binding is meant to let a Worker call a Workflow, so being forced to write one purely for registration always felt a bit off.
What changes
Now, if all you want is to define a Workflow, you can just put it in exports. It accepts the same settings as a binding — limits, schedules, and default_retention — so you don't lose any functionality. When you run wrangler deploy, Wrangler creates or updates the Workflow according to that configuration.
You can still declare a Workflow as both a binding and an export, as long as both point to the same class and never set the same setting to different values. Also keep in mind that a workflows binding to a Workflow in another Worker can't reuse the same name as a Workflow export in this Worker, since Workflow names are unique per account.
Dive Deep
An export accepts the same three settings as a binding.
limits— caps such as the number of steps (e.g.steps: 25000)schedules— cron-style scheduled runsdefault_retention— the default retention period
This feature requires Wrangler 4.139.0 or above, so make sure to update before trying it out.
Wrap-up
- You can now declare a Workflow through
exportswithout needing aworkflowsbinding - Supported settings are
limits,schedules, anddefault_retention - You can combine a binding and an export, but they must reference the same class and matching settings
- Workflow names are unique per account, so watch out for name clashes between bindings and exports
- Requires Wrangler 4.139.0 or above
- A nice quality-of-life update for Cloudflare Workers developers who just want to define a Workflow without calling it themselves!