Vercel Cron
Generate Vercel cron config from discovered crons.
Use Vercel Cron when Vercel should trigger scheduled work for the app instead of an in-process scheduler.
Configure Vercel
nuxt.config.ts
export default defineNuxtConfig({
modules: ['@vitehub/cron/nuxt'],
cron: {
provider: 'vercel',
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.
.env
CRON_SECRET=your-shared-secret
ViteHub does not load .env files for you. Your app or runtime must load them into process.env.
Define a scheduled cron
server/crons/daily-digest.ts
import { defineCron } from '@vitehub/cron'
export default defineCron(['0 12 * * 1'], async () => {
return { ok: true }
})
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'. |
On Nitro or Nuxt, keep
cron.provider = 'vercel' in config and use NITRO_CRON_SECRET or NUXT_CRON_SECRET when you want runtime-specific secrets without changing source config.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.