Integrations / Platforms / Vercel

โ–ณ

Vercel

Add LogIt to Vercel serverless functions and Edge functions. The SDK works in both Node.js and Edge runtimes.


Install

bash
npm install logit

Serverless function (Node.js runtime)

ts
// 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 });
}

Edge function

ts
// 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" },
  });
}

Environment variable

Add LOGIT_API_KEY in your Vercel project under Settings โ†’ Environment Variables.

bash
LOGIT_API_KEY=lk_live_xxxxxxxxxxxxxxxx

Tip: Set it for Production, Preview, and Development so your local vercel dev picks it up automatically.

Ready to connect Vercel?

7-day free trial. No credit card required.

Start free