Local Runtime Reference
This page consolidates the local runtime reference that used to be spread across multiple pages.
Config files
Cronlet loads the first config file it finds in this order:
cronlet.config.tscronlet.config.mtscronlet.config.ctscronlet.config.jscronlet.config.mjscronlet.config.cjs
Example:
import { defineConfig } from "cronlet";
export default defineConfig({ jobsDir: "./src/jobs", deploy: { prefix: "/api/cron", vercel: { maxDuration: 60, }, },});Config fields
jobsDir?: string
Path to the jobs directory.
deploy.prefix?: string
Route prefix used by cronlet deploy --platform vercel.
Default:
/api/crondeploy.vercel.maxDuration?: number
Maximum function duration in seconds for generated Vercel route files.
Directory resolution
Commands resolve the jobs directory in this order:
--dir <path>jobsDirfrom config- auto-detect (
./jobs,./src/jobs,./app/jobs)
Job model
A local cronlet job is a default export from schedule():
import { schedule, daily } from "cronlet";
export default schedule(daily("09:00"), async (ctx) => { await sendReport(ctx.jobId);});Deterministic job IDs
Job IDs are:
config.nameif provided- otherwise file path relative to the resolved jobs directory
Schedule builders
every("15m")daily("09:00")weekly("fri", "09:00")monthly(1, "09:00")monthly("last-fri", "17:00")cron("0 9 * * 1-5")
Job context
interface JobContext { jobId: string; jobName: string; runId: string; scheduledAt: Date; startedAt: Date; attempt: number; signal: AbortSignal;}Concurrency
concurrency: "skip"defaultconcurrency: "allow"concurrency: "queue"
catchup: true only applies to concurrency: "skip".
CLI commands
cronlet init
npx cronlet initcronlet dev
npx cronlet devnpx cronlet dev --port 4000npx cronlet dev --dir ./jobsnpx cronlet dev --no-watchcronlet list
npx cronlet listcronlet run <job-id>
npx cronlet run billing/sync-stripecronlet validate
npx cronlet validatecronlet deploy --platform vercel
npx cronlet deploy --platform vercelnpx cronlet deploy --platform vercel --dry-runLocal dev behavior
cronlet dev starts:
- discovery
- scheduler
- dashboard API + UI
- file watcher
The local dashboard updates primarily via Server-Sent Events (/api/events) with polling fallback.
Deployment notes
Vercel
Cronlet can generate Vercel cron routes and vercel.json cron entries.
Important caveats:
- Vercel cron is minute-granularity, not second-granularity.
- Vercel cron runs in UTC.
- Retry + timeout settings can exceed function limits if you are careless.
- Monthly
last-*schedules compile toLsyntax, which depends on platform support.
Long-lived worker
For Docker, Fly, Railway, Kubernetes, or any Node host:
import { createWorker } from "cronlet";
const worker = createWorker({ dir: "./src/jobs" });await worker.start();Troubleshooting
No jobs found
Check directory resolution, then run:
npx cronlet listDuplicate job IDs
Rename one file or set distinct explicit config.name values.
Invalid durations
Use integer + unit values such as:
100ms30s5m1h1d
Vercel jobs not firing
Check generated routes, vercel.json, prefix alignment, schedule compatibility, and deployment logs.