Documentation Index
Fetch the complete documentation index at: https://mintlify.com/cloudflare/partykit/llms.txt
Use this file to discover all available pages before exploring further.
partywhen is a task-scheduling library built on Durable Object Alarms. It lets you schedule tasks by delay, cron expression, or specific date/time — all from a single Scheduler Durable Object. Each task carries a description, a JSON payload, and a callback that fires when the task runs.
Installation
Class: Scheduler
Scheduler is the Durable Object class that manages and fires tasks. Export it from your Worker and bind it in wrangler.jsonc:
wrangler.jsonc Configuration
DeclareScheduler as a Durable Object with SQLite storage and add a migration tag:
Accessing a Scheduler Instance
Obtain a stub via the standard Durable Object API:Method: scheduler.scheduleTask(task)
Schedule a new task. The task runs according to itstype and fires the specified callback.
Task fields
An optional human-readable label for the task. Can be used to query or identify the task later.
An optional JSON-serializable object passed to the callback when the task fires.
Determines when the task runs:
"delayed"— run after a delay (requiresdelayInSeconds)"cron"— run on a cron schedule (requirescron)"scheduled"— run at a specificDate(requirestime)"no-schedule"— never runs automatically; useful for tasks that must be manually removed
Required when
type is "delayed". Number of seconds to wait before firing.Required when
type is "cron". A standard 5-field cron expression, e.g. "0 18 * * 5" (every Friday at 6 pm UTC).Required when
type is "scheduled". The exact Date at which to fire the task.What to invoke when the task fires. See callback types below.