Skip to content

Healthcheck Next.js examples

import { createNextMetricsRoute } from "@nexload-sdk/healthcheck-next";
import { health } from "@/lib/health";
export const runtime = "nodejs";
export const dynamic = "force-dynamic";
export const { GET, HEAD } = createNextMetricsRoute(health, {
format: "openmetrics",
scope: "all",
prefix: "web",
protect: { bearerToken: process.env.METRICS_TOKEN! },
});

Executable route behavior: route.test.mjs.

The documentation example is type-checked in CI: healthcheck-next.ts.