Vercel Cron

Generate Vercel cron config from discovered crons.

Vercel Cron fits Vercel-hosted apps that want scheduled work without running an in-process scheduler. ViteHub discovers cron files, generates internal cron routes, and writes Vercel Build Output cron entries during build.

Configure Vercel

nitro.config.ts
import { defineNitroConfig } from 'nitro/config'

export default defineNitroConfig({
  modules: ['@vitehub/cron/nitro'],
  cron: {
    provider: 'vercel',
    // Optional: protect generated cron routes with a shared secret.
    secret: process.env.CRON_SECRET,
  },
})

secret is optional. Set it only when you want to protect generated cron routes. If you omit it, ViteHub falls back to CRON_SECRET.

Define a scheduled cron

server/crons/daily-digest.ts
import { defineCron } from '@vitehub/cron'

export default defineCron(async () => {
  return { ok: true }
}, {
  schedules: ['0 12 * * 1'],
})

What changes on Vercel

ConcernBehavior
Build outputViteHub writes cron entries into .vercel/output/config.json.
Runtime routeViteHub generates internal routes under /_vitehub/cron/<name> for scheduled execution.
Route protectionGenerated routes require Authorization: Bearer <secret> when cron.secret or CRON_SECRET is set.
Invalid fieldsNode-only fields such as timezone, overlap, startAt, stopAt, and maxRuns are rejected when cron.provider = 'vercel'.

Scheduled payload

Scheduled executions include a payload with:

  • scheduledTime
  • source: 'vercel-cron'
  • cron from the x-vercel-cron header when it is present

Manual execution still uses runCron(name, { payload?, context? }).

Choose Vercel when the rest of the app already deploys there and you want the platform to own scheduling and route invocation.