TypeScript SDK
Send events, ask people for decisions and get the answers, from TypeScript or JavaScript with @emitkit/js.
@emitkit/js wraps EmitKit’s API for TypeScript and JavaScript on the
server: Node 20.3+, Bun, Deno, Cloudflare Workers, or anything with fetch. It
has no dependencies, and every request and response is typed.
Install
npm install @emitkit/js@nextpnpm add @emitkit/js@nextbun add @emitkit/js@nextSend an event
import { EmitKit } from "@emitkit/js";
const emitkit = new EmitKit(); // reads EMITKIT_API_KEY
const event = await emitkit.events.create({
channelName: "payments",
title: "New subscription",
icon: "💰",
metadata: { amount: 49, currency: "USD", plan: "pro" },
userId: "user_123",
});
console.log(event.id);
The API key selects the Project, and channelName selects
or creates a Channel in it. Keep the key on the server: never put it in a
browser bundle or a public environment variable. Pass it explicitly with
new EmitKit("emitkit_…") if it isn’t in EMITKIT_API_KEY.