A complete guide for indie developers and free-tier builders: from zero to a live uptime dashboard at your own domain.
Why Your Side Project Needs This
You've deployed your Next.js blog or SaaS app. It's live, it works, and you're proud of it. But here's the uncomfortable truth: you have no idea when it goes down.
Your MongoDB Atlas free cluster might hit its connection limit at 2 AM. Your Vercel serverless function might cold-start and fail silently. A missing environment variable after a redeployment could break auth for every user — and you won't know until someone tweets at you.
Professional teams solve this with status pages and uptime monitors. Tools like Datadog and StatusPage.io charge $20–$400/month. But if you're on the indie/free stack — Vercel Hobby, MongoDB Atlas free tier, Clerk free plan — you don't have that budget.
This guide shows you how to build the same thing for absolutely free using:
- A custom
/api/healthendpoint in Next.js - cron-job.org for free uptime monitoring
- A public status page at your own subdomain (e.g.,
health.yoursite.com) - Cloudflare DNS (free tier) for the custom domain
Part 1: Why Not Just Ping Your Homepage?
The instinct is to point your monitor at https://yoursite.com and call it a day. Don't. Here's why:
cron-job.org has a 64 KB response size limit. A modern Next.js homepage easily exceeds that with HTML, inline styles, hydration scripts, and meta tags. The monitor will fail with "output too large" : marking your site as down even when it's perfectly healthy.
A dedicated /api/health endpoint solves this by returning a tiny JSON payload (~500 bytes) that tells you not just "is the server responding" but "is every service my app depends on actually working?"
This is the difference between a smoke alarm and a fire detection system.
Part 2: Building the Health Check System
The Architecture
The health system has three layers:
All 8 checks fire simultaneously. Total response time = the slowest single check, not the sum of all checks.
Step 1 — Create the Core Utilities
Create src/lib/health/checks.js. Start with the two foundational utilities every check depends on.
Utility 1: maskSensitiveValues — Security guard for error messages
When checks fail, JavaScript errors often contain your raw secrets in the message. For example, a MongoDB auth failure exposes your full connection string including password. This utility sanitizes errors before they reach your public JSON response:
Each regex targets a specific secret format. The truncation at 180 characters prevents enormous error messages from inflating your JSON response.
Utility 2: withTimeout — The race condition pattern
External services can hang indefinitely. A MongoDB Atlas cold connection can take 10+ seconds. Without a timeout, one slow service freezes your entire health check. This utility uses Promise.race() to enforce a hard deadline:
Why pass a function (promiseFactory) instead of a Promise directly? A Promise starts executing the moment it's created. By passing a factory function, withTimeout controls exactly when the work starts — only after both race competitors are set up simultaneously.The finally block is critical: if the check finishes before the timeout, the setTimeout is still alive in Node's event loop. clearTimeout cancels it, preventing ghost timers from accumulating.
Utility 3: runCheck — The universal wrapper
Every individual check function gets wrapped in runCheck, which handles timing, error catching, and severity routing:
The critical flag is the key design decision here. It separates "my site is completely broken" from "a non-essential service is misconfigured":
critical: true + errorcritical: false + error | |
status = 'fail' | status = 'degraded' |
| HTTP 503 returned | HTTP 200 returned |
| cron-job.org marks site DOWN | cron-job.org marks site UP |
| You get emergency alert | You get a warning |
Step 2 — Write the Individual Checks
Now write the actual check functions. The pattern is consistent: validate config first, then make a real network call if config exists.
For services where you only store config (no real-time API call needed), just validate the env vars exist:
Step 3 — Orchestrate Everything in buildHealthReport
Step 4 — The Route Handler
Why force-dynamic? Without it, Next.js may statically cache the route at build time. Your health check would return the same stale JSON forever — completely defeating the purpose.Why runtime = 'nodejs'? The Edge runtime doesn't support Mongoose, Nodemailer, or many Node.js APIs. Since your checks depend on these, you need the full Node.js environment.Deploy and test it:
You should get a clean JSON response in ~400ms or less.
Part 3: Setting Up cron-job.org for Free Monitoring
Now that your health endpoint is live, you need something to call it every minute and track results. cron-job.org does this completely free — no credit card, no trial period.
Step 1 — Create a Free Account
Sign up at console.cron-job.org. The free tier includes unlimited cronjobs running up to every minute, plus a status page feature.
Step 2 — Create Your Monitor Job
- Click "Create cronjob"
- Fill in the settings:
| FieldValue | |
| Title | Health Monitor - yoursite.com |
| URL | https://yoursite.com/api/health |
| Execution schedule | Every minute |
| Request method | GET |
| Expected HTTP status | 200 |
- Under Advanced → Notifications, enable email alerts for failures
- Save the job
cron-job.org will now hit your health endpoint every 60 seconds and log the response time and status.
Step 3 — Create Your Status Page
- Go to Status Pages in the sidebar
- Click "Create status page"
- Give it a name (e.g., "Basak Speaks Status")
- Click "Add component" and select your monitor job
- Label the component (e.g., "Blog API", "Database", etc.)
- Under Custom Domain, enter:
health.yoursite.com - Save
Step 4 — Wire Up Your DNS (Cloudflare)
In Cloudflare DNS for your domain, add one record:
| TypeNameTargetProxy | |||
CNAME | health | status.cron-job.org | DNS only (grey cloud) ⚠️ |
The proxy must be OFF (grey cloud). If Cloudflare proxies the request, it intercepts the SSL certificate issuance that cron-job.org needs to provision HTTPS for your subdomain. DNS-only mode lets cron-job.org handle TLS directly.
After DNS propagates (usually under 5 minutes with Cloudflare), visit health.yoursite.com. You'll have a live public status page showing:
- Real-time uptime percentage
- Response latency graph
- Incident history
- Current service status
All for free. Forever.
Part 4: What Your Stack Costs
For a typical free-tier Next.js project pinged every minute by cron-job.org:
| ResourceMonthly UsageFree LimitStatus | |||
| Vercel function invocations | 43,200 | 1,000,000 | ✅ 4% used |
| Vercel function duration (GB-hrs) | ~4.2 GB-hrs | 100 GB-hrs | ✅ 4% used |
| Vercel CPU hours | ~0.24 hrs | 4 CPU-hrs | ✅ 6% used |
| cron-job.org jobs | 1 | Unlimited | ✅ Free |
| cron-job.org status page | 1 | Included | ✅ Free |
| Cloudflare DNS | 1 CNAME | Unlimited | ✅ Free |
Total monthly cost: $0.00. The health check API uses roughly 4% of Vercel Hobby's limits. You have plenty of headroom.
Bonus: Make Your /api/health Secure
Since your health endpoint reveals service names and configuration state, consider protecting it from public scraping while still allowing cron-job.org to access it:
Then in cron-job.org's job settings, add a custom request header:
Set HEALTH_SECRET in your Vercel environment variables, and your endpoint is now authenticated — cron-job.org gets in, random internet users don't.
What You've Built
At the end of this guide, you have:
- A production-grade health API that checks every dependency your app has
- Sensitive data masked from public error messages
- 2-second timeouts preventing hung requests
- Parallel checks for fast response times
- A public status page at
health.yoursite.comwith SSL - Real-time uptime monitoring with email alerts on failure
- Zero dollars spent, zero infrastructure managed
The next time your MongoDB Atlas free cluster hits its connection limit at 2 AM, you'll get an email before your users notice. That's the whole point.



