Node Cron
Configure in-process scheduling for local crons and lightweight cron tasks.
Use Node when the app process itself should own cron scheduling. The scheduler runs in process through Croner and exposes the broadest schedule feature set.
Configure Node
nuxt.config.ts
export default defineNuxtConfig({
modules: ['@vitehub/cron/nuxt'],
cron: {
provider: 'node',
timezone: 'Europe/Copenhagen',
overlap: 'prevent',
},
})
Use top-level cron fields for app-wide Node schedule defaults. Use defineCron(schedules, handler) when one cron needs different schedule behavior.
Define a scheduled cron
server/crons/daily-digest.ts
import { defineCron } from '@vitehub/cron'
export default defineCron([{
cron: '0 12 * * 1',
timezone: 'Europe/Copenhagen',
overlap: 'prevent',
maxRuns: 3,
}], async () => {
return { ok: true }
})
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.