Firebase Cloud Functions are powerful, but scheduling background tasks can be tricky without a Blaze plan. Luckily, you can run cron jobs for free by combining Firebase with GitHub Actions or third-party schedulers. This article explains how to build a serverless function in Firebase and trigger it on a schedule without spending a dime.
Step 1: Create a Firebase Function
Inside your Firebase project, add a function in functions/index.js
(or functions/src/index.ts
if using TypeScript):
const functions = require("firebase-functions");
exports.scheduledTask = functions.https.onRequest((req, res) => {
console.log("Scheduled function triggered");
res.send("Function executed");
});
Step 2: Deploy Your Function
Make sure Firebase CLI is installed and authenticated:
firebase deploy --only functions
Once deployed, note the public HTTPS URL of the function. It will look something like:
https://[region]-[project-id].cloudfunctions.net/scheduledTask
Step 3: Schedule With GitHub Actions
Create a GitHub Actions workflow to run the task periodically:
# .github/workflows/firebase-cron.yml
name: Firebase Scheduled Trigger
on:
schedule:
- cron: '0 9 * * *' # every day at 9am UTC
jobs:
run-cron:
runs-on: ubuntu-latest
steps:
- name: Trigger Firebase function
run: curl https://[region]-[project-id].cloudfunctions.net/scheduledTask
Bonus: Use External Cron Services
Tools like cron-job.org, Upstash Scheduler, or EasyCron offer free cron job scheduling. Point their HTTP request to your Firebase function URL at the desired interval.
Pros and Cons
✅ Pros
- Totally free with Firebase's Spark plan
- No need for paid scheduling services
- Flexible triggers using GitHub or third-party tools
⚠️ Cons
- No native cron support without Blaze plan
- Delay possible depending on trigger service
🚀 Alternatives
- Firebase Scheduled Functions: Built-in but requires Blaze billing
- Trigger.dev: Self-hosted or cloud-based scheduling framework
- Cloudflare Workers with Cron Triggers: Native support and generous free tier
Conclusion
You don’t need a paid plan to run scheduled jobs on Firebase. By triggering your HTTPS functions through external tools, you can automate tasks efficiently and at no cost — great for background tasks, pings, data refreshes, and more.
If this helped you out, you can support me here: buymeacoffee.com/hexshift