Integrations / Frameworks / Hono
Log events from Hono route handlers. Works on every runtime Hono supports โ Cloudflare Workers, Bun, Node.js, Deno.
npm install logit hono
import { Hono } from "hono";
import { init } from "logit";
const logit = init({ token: process.env.LOGIT_API_KEY! });
const app = new Hono();
app.post("/signup", async (c) => {
const { email, plan } = await c.req.json<{ email: string; plan: string }>();
// ... create user
await logit.now("signups", {
event: "New user signed up",
description: `${email} joined on ${plan}`,
icon: "๐ค",
notify: true,
tags: { plan },
metadata: { email },
});
return c.json({ ok: true });
});
app.use("*", async (c, next) => {
await next();
if (c.res.status >= 500) {
await logit.now("errors", {
event: "5xx error",
description: `${c.req.method} ${c.req.path} โ ${c.res.status}`,
icon: "โ",
notify: true,
});
}
});
Use the Bindings pattern to inject secrets at runtime:
type Env = { LOGIT_API_KEY: string };
const app = new Hono<{ Bindings: Env }>();
app.post("/event", async (c) => {
const logit = init({ token: c.env.LOGIT_API_KEY });
await logit.now("events", { event: "Worker event", icon: "โก" });
return c.text("ok");
});
Ready to connect Hono?
7-day free trial. No credit card required.