Skip to content

Overview & Quick Start

Next.js App Router Health Routes

@nexload-sdk/healthcheck-next

v2.1.0 Stable Released

Next.js App Router route factories for @nexload-sdk/healthcheck.

Next.js App RouterNode.js

@nexload-sdk/healthcheck-next binds @nexload-sdk/healthcheck to Next.js App Router Route Handlers. It automatically enforces Cache-Control: no-store headers, prevents static optimization of health endpoints, maps status codes to Kubernetes expectations, and provides token-based proxy protection.


app/api/health/route.ts
import { createHealthManager } from "@nexload-sdk/healthcheck";
import { createNextHealthRoute } from "@nexload-sdk/healthcheck-next";
const health = createHealthManager({
service: { name: "web-storefront" },
});
export const { GET } = createNextHealthRoute({
health,
scope: "readiness",
});

  • Next.js App Router Handlers: Export GET and HEAD handlers compliant with Next.js 14, 15, and canary.
  • Zero-Cache Guarantees: Forces force-dynamic behavior with Cache-Control: no-store, no-cache, must-revalidate to prevent CDN and browser caching.
  • HTTP Status Code Mapping: Returns 200 OK for "ok" and "degraded", and 503 Service Unavailable for "unhealthy".
  • Diagnostics Authorization: Protect operational details behind Bearer tokens or secret headers when exposing internal metrics.

Terminal window
pnpm add @nexload-sdk/healthcheck-next @nexload-sdk/healthcheck next

With alternative package managers:

Terminal window
# npm
npm install @nexload-sdk/healthcheck-next @nexload-sdk/healthcheck next
# bun
bun add @nexload-sdk/healthcheck-next @nexload-sdk/healthcheck next

Requires Next.js >=14.0.0 and Node.js >=20.9.0.