A health check endpoint is the simplest and most effective way to know if your Next.js app is running correctly. It's a dedicated route that returns the status of your application and its dependencies — database, cache, external APIs — in a machine-readable format.
In this guide, you'll create a health check endpoint in Next.js and then set up automated external monitoring to check it from multiple geographic regions.
What Is a Health Check Endpoint?
A health check is a lightweight API route (typically GET /api/health) that verifies your application can serve requests and that critical dependencies are reachable. It should return a JSON response with the overall status and individual component statuses.
A good health check verifies three things: (1) the application process is running, (2) the database connection is active, and (3) critical external services are reachable.
Step 1: Create a Basic Health Endpoint
In Next.js App Router, create app/api/health/route.ts that returns a JSON object with status, timestamp, and process uptime. Return HTTP 200 for healthy, 503 for unhealthy.
The simplest version just confirms the app is running. Return { "status": "healthy", "timestamp": "...", "uptime": 12345 } with a 200 status code.
Step 2: Add Dependency Checks
A basic health check that always returns 200 isn't very useful. Add checks for your critical dependencies:
- Database — Run a simple query like
SELECT 1and measure the latency. If it fails or takes too long, mark the database as unhealthy. - External APIs — If your app depends on Stripe, Auth0, or any third-party API, ping their health endpoints and verify they respond.
- Memory usage — Check
process.memoryUsage()and flag if heap usage exceeds 90% of available memory.
Return a structured response that lists each dependency with its status and latency. If any dependency is unhealthy, return HTTP 503 instead of 200. This lets external monitoring tools detect partial failures.
Step 3: Monitor Externally with Nurbak
A health check endpoint that nobody checks is useless. You need an external service that calls your /api/health route regularly from outside your infrastructure.
Why external? Because if your server crashes, it can't check itself. You need checks from a completely separate system.
With Nurbak, add 5 lines to your instrumentation.ts file and your health endpoint will be checked automatically from up to 4 global regions (US, Brazil, France, Japan) every 1-5 minutes.
Each check captures detailed metrics beyond just the HTTP status code: DNS lookup time, TLS handshake time, Time to First Byte (TTFB), response size, and the full response body. This means you can see not just IF your health check passed, but HOW FAST it responded from each region.
Step 4: Configure Alerts
Set up alert rules for your health endpoint in the Nurbak dashboard:
- API Down — triggers when the endpoint returns a non-200 status or is unreachable
- High Latency — triggers when response time exceeds your threshold (e.g., 2000ms)
- Error Rate — triggers when the failure percentage exceeds your threshold
- SSL Expiry — alerts before your certificate expires
Send alerts to Slack (Pro plan), email (all plans), WhatsApp, or SMS. Nurbak uses anti-spam logic: you get one notification when an incident starts, and one when it resolves. No flood of repeated alerts.
Multi-Region Health Checks
Your app might be healthy from Virginia but failing from Tokyo. Multi-region checks detect geographic issues that single-location monitoring misses. Common causes include CDN misconfigurations, DNS propagation delays, and regional infrastructure outages.
Nurbak checks from Virginia (US), Sao Paulo (Brazil), Paris (France), and Tokyo (Japan). If your health check fails from one region but passes from others, you know it's a regional issue — not a full outage.
Best Practices
- Keep it fast — Health checks should respond in under 500ms. Don't query every table; a simple SELECT 1 is enough for database checks.
- Don't cache — Health checks should always run fresh. Add
Cache-Control: no-cacheheaders. - Include version info — Return your app version or git commit hash. Useful for verifying deployments.
- Use structured JSON — Return consistent JSON so monitoring tools can parse component statuses.
- Separate liveness from readiness — A liveness check confirms the process is running. A readiness check confirms all dependencies are available. Consider having both.
Free Tier
Nurbak's free plan includes 3 endpoints (perfect for monitoring your health, main API, and webhook routes), health checks every 5 minutes from 1 region, and email alerts. No credit card required. For 1-minute checks from all 4 regions with Slack/WhatsApp alerts, upgrade to Pro at $29/month.

