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

FieldUse it for
cronThe cron expression that should trigger the cron.
timezoneRun the cron relative to a specific timezone.
overlapAllow or prevent overlapping executions.
startAtDelay scheduling until a specific date or timestamp.
stopAtStop scheduling after a specific date or timestamp.
maxRunsLimit 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:

FunctionSignatureUse it for
startScheduleRunner(options?: { waitUntil?: (promise: Promise<unknown>) => void }) => voidStart 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.