Integrations / Platforms / Vercel
Add LogIt to Vercel serverless functions and Edge functions. The SDK works in both Node.js and Edge runtimes.
npm install logit
// api/signup.ts (Vercel /api directory)
import type { VercelRequest, VercelResponse } from "@vercel/node";
import { init } from "logit";
const logit = init({ token: process.env.LOGIT_API_KEY! });
export default async function handler(req: VercelRequest, res: VercelResponse) {
if (req.method !== "POST") return res.status(405).end();
const { email } = req.body as { email: string };
await logit.now("signups", {
event: "New user signed up",
description: email,
icon: "๐ค",
notify: true,
metadata: { email },
});
res.json({ ok: true });
}
// api/edge-event.ts
import { init } from "logit";
export const config = { runtime: "edge" };
export default async function handler(req: Request) {
const logit = init({ token: process.env.LOGIT_API_KEY! });
await logit.now("events", {
event: "Edge function called",
icon: "โก",
notify: false,
});
return new Response(JSON.stringify({ ok: true }), {
headers: { "Content-Type": "application/json" },
});
}
Add LOGIT_API_KEY in your Vercel project under Settings โ Environment Variables.
LOGIT_API_KEY=lk_live_xxxxxxxxxxxxxxxx
Tip: Set it for Production, Preview, and Development so your local
vercel devpicks it up automatically.
Ready to connect Vercel?
7-day free trial. No credit card required.