Running scheduled tasks in a serverless environment like Vercel might seem challenging, especially since Vercel doesn’t have built-in cron job support. But with a clever combination of Vercel’s edge functions, GitHub Actions, or external schedulers like Upstash or cron-job.org, you can run cron jobs completely for free and reliably.
Why Use Cron Jobs on Vercel?
- Perform background maintenance (e.g. data cleanup, backups)
- Trigger API calls or workflows at fixed intervals
- Run periodic scripts in a cost-effective and scalable way
Method 1: Using GitHub Actions (Free and Serverless)
This method uses GitHub Actions to ping a deployed Vercel edge function or API route on a schedule.
Step 1: Create Your Vercel API Route
// /api/scheduled-task.js
export default async function handler(req, res) {
// Your scheduled logic here
console.log("Scheduled task triggered");
res.status(200).json({ message: "Task complete" });
}
Step 2: Add GitHub Action to Trigger the API
# .github/workflows/cron.yml
name: Trigger Vercel Cron
on:
schedule:
- cron: '*/30 * * * *' # every 30 minutes
jobs:
ping-vercel:
runs-on: ubuntu-latest
steps:
- name: Curl scheduled endpoint
run: curl https://your-vercel-app.vercel.app/api/scheduled-task
Method 2: Using Upstash Scheduler (Also Free)
Upstash provides a free cron-based HTTP scheduler. It's simple and works great with serverless endpoints.
- Create an account at Upstash Scheduler
- Set up a cron rule pointing to your Vercel API route
That’s it — no infra required!
Pros and Cons
✅ Pros
- Entirely free setup with Vercel + GitHub or Upstash
- No infrastructure or servers needed
- Scales perfectly with Vercel's edge/runtime
⚠️ Cons
- GitHub Actions have cold starts; not precise for real-time events
- External schedulers mean slight external dependencies
🚀 Alternatives
- cron-job.org: Free public HTTP scheduler, no login required
- Trigger.dev: Self-hostable advanced cron/scheduler
Conclusion
You don’t need expensive services or persistent infrastructure to run cron jobs on Vercel. Whether using GitHub Actions, Upstash, or other HTTP-based solutions, you can build reliable scheduled tasks while keeping your setup clean, fast, and entirely free.
If this helped you or saved you money, support future content: buymeacoffee.com/hexshift