Skip to content
EmitKitDocs
Esc
↑↓navigate↵open⌘Jpreview
On this page

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@next
pnpm add @emitkit/js@next
bun add @emitkit/js@next

Send 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.

Was this page helpful?