Node SDK
@kinglet/sdk-node is a zero-dependency batching client. Events buffer
in-process and ship as a single NDJSON batch — 200 events or every second,
whichever comes first. A failed batch is re-queued (with a cap) and reported
through onError, so your app never blocks on logging.
Install
Section titled “Install”npm install @kinglet/sdk-nodeimport { createLogger } from "@kinglet/sdk-node";
const log = createLogger({ url: "http://localhost:8080", // your Kinglet server token: process.env.KINGLET_KEY!, // API key with the ingest scope (kl_…) service: "my-app", env: "prod",});
log.info("user signed in", { userId: 42 });log.error("payment failed", { orderId: 1234, code: "card_declined" });
// best-effort final flush in your shutdown handlerawait log.close();Options
Section titled “Options”| Option | Default | What it does |
|---|---|---|
url |
— | Kinglet base URL (required) |
token |
— | ingest token (required) |
service / env |
— | tagged onto every event |
batchSize |
200 |
flush after this many buffered events |
flushMs |
1000 |
flush at least this often |
onError |
— | called when a flush fails; the batch is re-queued |