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
| Concern | Behavior |
|---|---|
| Build output | ViteHub writes cron entries into .vercel/output/config.json. |
| Runtime route | ViteHub generates internal routes under /_vitehub/cron/<name> for scheduled execution. |
| Route protection | Generated routes require Authorization: Bearer <secret> when cron.secret or CRON_SECRET is set. |
| Invalid fields | Node-only fields such as timezone, overlap, startAt, stopAt, and maxRuns are rejected when cron.provider = 'vercel'. |
Scheduled payload
Scheduled executions include a payload with:
scheduledTimesource: 'vercel-cron'cronfrom thex-vercel-cronheader 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.