Node Cron
Configure in-process scheduling for local crons and lightweight cron tasks.
Node is the local and self-hosted scheduler for cron. The scheduler runs schedules in process through Croner and gives you the broadest schedule feature set.
Configure Node
nitro.config.ts
import { defineNitroConfig } from 'nitro/config'
export default defineNitroConfig({
modules: ['@vitehub/cron/nitro'],
cron: {
provider: 'node',
timezone: 'Europe/Copenhagen',
overlap: 'prevent',
},
})
Use top-level cron fields for app-wide Node schedule defaults. Use defineCron(..., options) when one cron needs different schedule behavior.
Define a scheduled cron
server/crons/daily-digest.ts
import { defineCron } from '@vitehub/cron'
export default defineCron(async () => {
return { ok: true }
}, {
schedules: [{
cron: '0 12 * * 1',
timezone: 'Europe/Copenhagen',
overlap: 'prevent',
maxRuns: 3,
}],
})
String schedules still work. Use schedule objects when you need Node-only controls.
Node schedule fields
| Field | Use it for |
|---|---|
cron | The cron expression that should trigger the cron. |
timezone | Run the cron relative to a specific timezone. |
overlap | Allow or prevent overlapping executions. |
startAt | Delay scheduling until a specific date or timestamp. |
stopAt | Stop scheduling after a specific date or timestamp. |
maxRuns | Limit how many times the schedule should fire. |
Runtime helpers
Manual execution uses @vitehub/cron with runCron(name, { payload?, context? }).
When you need in-process schedule control, use the Node-only helpers from @vitehub/cron:
| Function | Signature | Use it for |
|---|---|---|
startScheduleRunner | (options?: { waitUntil?: (promise: Promise<unknown>) => void }) => void | Start the in-process Croner scheduler for all registered crons. |
getCronsForExpression | (cron: string) => string[] | Return the cron names registered under a given cron expression. |
runCronsForExpression | (cron: string, ctx?: { payload?, context? }) => Promise<unknown[]> | Run every cron registered under a given cron expression. |
Choose Node when your Nitro server stays alive long enough to own cron execution itself. Move to Cloudflare or Vercel when the platform should trigger schedules for you.