Skip to content
sproutboatDocs
Esc
↑↓navigate↵open⌘Jpreview
On this page

Cron

Scheduled triggers delivered to a scheduled(controller, env, ctx) handler.

Configuration

"triggers": { "crons": ["0 3 * * *"] }

Each entry is a 5-field cron expression in UTC.

Usage

export default {
  async fetch(request, env, ctx) {
    return new Response("ok");
  },

  async scheduled(controller, env, ctx) {
    // controller.cron -> "0 3 * * *", controller.scheduledTime -> epoch milliseconds
    console.log(`${controller.cron} fired for ${new Date(controller.scheduledTime).toISOString()}`);
  },
} satisfies ExportedHandler<Env>;

scheduled receives env second from compatibility date 2026-09-28, like fetch. Before it, the handler is scheduled(event) and reads env as a global.

  • The handler: the full fetch, scheduled and queue export

Was this page helpful?