Converting Deno.cron Schedules and Handlers to Worker scheduled() Exports
How to extract Deno.cron schedules into wrangler.jsonc triggers.crons, generate typed scheduled() dispatchers, and access env bindings cleanly.
1. Extracting Declarative Schedules to wrangler.jsonc
In Deno Deploy, Deno.cron(name, schedule, handler) registers background schedules inline inside application code at startup. In Cloudflare Workers, cron schedules live declaratively in wrangler.jsonc under triggers.crons so Cloudflare's edge scheduler invokes your Worker's scheduled() export reliably.
{
"compatibility_date": "2026-11-01",
"compatibility_flags": ["nodejs_compat"],
"triggers": {
"crons": ["*/15 * * * *"]
}
}
2. Dispatching Multiple Schedules and Threading Env
Our AST codemod extracts each Deno.cron callback into an isolated async function, maps Deno.env.get() calls to the Worker Env binding (or AsyncLocalStorage getEnv() context for deep helper calls), and emits a switch (controller.cron) dispatcher inside export default { async scheduled(controller, env, ctx) }.