Integrations / Frameworks / Bun
Track events from Bun.serve handlers or Elysia apps. Bun's built-in fetch means the SDK works with zero extra setup.
bun add logit
import { init } from "logit";
const logit = init({ token: Bun.env.LOGIT_API_KEY! });
Bun.serve({
port: 3000,
async fetch(req) {
const url = new URL(req.url);
if (url.pathname === "/signup" && req.method === "POST") {
const { email } = await req.json() as { email: string };
await logit.now("signups", {
event: "New user signed up",
description: email,
icon: "๐ค",
notify: true,
metadata: { email },
});
return Response.json({ ok: true }, { status: 201 });
}
return new Response("Not found", { status: 404 });
},
});
import { Elysia, t } from "elysia";
import { init } from "logit";
const logit = init({ token: Bun.env.LOGIT_API_KEY! });
new Elysia()
.post("/signup", async ({ body }) => {
await logit.now("signups", {
event: "New user signed up",
description: body.email,
icon: "๐ค",
notify: true,
tags: { plan: body.plan },
});
return { ok: true };
}, {
body: t.Object({
email: t.String(),
plan: t.String(),
}),
})
.listen(3000);
# .env or Bun reads process.env directly
LOGIT_API_KEY=lk_live_xxxxxxxxxxxxxxxx
Ready to connect Bun?
7-day free trial. No credit card required.