Docs/Hono

Hono

Add monitoring to your Hono app. Works on Cloudflare Workers, Deno, Bun, and Node.js. Health endpoint, heartbeat push, and status badge.

1

Health endpoint

import { Hono } from "hono";

const app = new Hono();

app.get("/api/health", (c) => {
  return c.json({ status: "ok" });
});

export default app;
2

Heartbeat push (optional)

On Cloudflare Workers, use a scheduled handler. On other runtimes, use setInterval or a cron library.

Cloudflare Workers (wrangler.toml)

[triggers]
crons = ["*/5 * * * *"]

src/index.ts

export default {
  fetch: app.fetch,

  async scheduled(event, env, ctx) {
    const checks = {};

    // Database check (D1, Turso, etc.)
    const dbStart = Date.now();
    try {
      await env.DB.prepare("SELECT 1").run();
      checks.database = { status: "ok", latency: Date.now() - dbStart };
    } catch (err) {
      checks.database = { status: "error", latency: Date.now() - dbStart };
    }

    const hasError = Object.values(checks).some((c) => c.status === "error");

    await fetch("https://www.bluemonitor.org/api/v1/heartbeat", {
      method: "POST",
      headers: {
        Authorization: `Bearer ${env.BLUEMONITOR_API_KEY}`,
        "Content-Type": "application/json",
      },
      body: JSON.stringify({
        domain: "yourapp.com",
        status: hasError ? "error" : "ok",
        timestamp: new Date().toISOString(),
        checks,
      }),
    });
  },
};
3

Status badge

[![Status](https://www.bluemonitor.org/api/badge/your-domain-com)](https://www.bluemonitor.org/status/your-domain-com)
4

Bot tracking

PRO

Track which search engines, AI crawlers, and social bots visit your app. Add bot detection middleware to report visits to BlueMonitor. Requires a Pro plan.

Hono middleware

import { createMiddleware } from "hono/factory";

const BOT_PATTERNS = [
  { pattern: /Googlebot/i, name: "googlebot", category: "search_engine" },
  { pattern: /bingbot/i, name: "bingbot", category: "search_engine" },
  { pattern: /GPTBot/i, name: "gptbot", category: "ai_crawler" },
  { pattern: /ClaudeBot/i, name: "claudebot", category: "ai_crawler" },
  { pattern: /PerplexityBot/i, name: "perplexitybot", category: "ai_crawler" },
  { pattern: /Twitterbot/i, name: "twitterbot", category: "social" },
  { pattern: /facebookexternalhit/i, name: "facebookbot", category: "social" },
  { pattern: /AhrefsBot/i, name: "ahrefsbot", category: "seo" },
];

function identifyBot(ua) {
  for (const bot of BOT_PATTERNS) {
    if (bot.pattern.test(ua)) return bot;
  }
  return null;
}

const botTracking = createMiddleware(async (c, next) => {
  const ua = c.req.header("user-agent") || "";
  const bot = identifyBot(ua);
  if (bot) {
    // Use waitUntil on Workers, await on other runtimes
    const promise = fetch("https://www.bluemonitor.org/api/v1/bot-visits", {
      method: "POST",
      headers: {
        Authorization: `Bearer ${c.env?.BLUEMONITOR_API_KEY}`,
        "Content-Type": "application/json",
      },
      body: JSON.stringify({
        domain: "yourapp.com",
        visits: [{
          bot_name: bot.name,
          bot_category: bot.category,
          path: new URL(c.req.url).pathname,
          user_agent: ua,
        }],
      }),
    }).catch(() => {});
    if (c.executionCtx?.waitUntil) {
      c.executionCtx.waitUntil(promise);
    } else {
      await promise;
    }
  }
  await next();
});

app.use("*", botTracking);

View results in your dashboard under Bot Tracking.

Using an AI coding tool?

Paste this URL in Claude, Cursor, or Copilot and it will set up monitoring for your Hono app automatically.

https://www.bluemonitor.org/llm-hono.txt

Next steps