Developers
Stack'd SDK
Tiny, zero-dependency TypeScript client for the Stack'd webhook surface. Runs in Node, Deno, Bun, browsers, and edge workers.
Install
# via npm
npm install @stackd/sdk
# or copy src/lib/sdk/stackd-client.ts directlyVerify a webhook
HMAC-SHA256, timing-safe compare, WebCrypto under the hood.
import { StackdClient } from "@stackd/sdk";
const stackd = new StackdClient({
baseUrl: "https://stack-d.lovable.app",
});
// 1. Verify an incoming webhook
export async function handleWebhook(req: Request) {
const raw = await req.text();
const sig = req.headers.get("x-stackd-signature") ?? "";
const ok = await stackd.verifyWebhookSignature(raw, sig, process.env.STACKD_SECRET!);
if (!ok) return new Response("bad sig", { status: 401 });
const event = await stackd.parseEvent(raw);
switch (event.type) {
case "session.completed": /* … */ break;
case "achievement.unlocked": /* … */ break;
}
return new Response("ok");
}Event types
session.completedA user finished a focus sessionsession.startedA user began a focus sessionachievement.unlockedA user earned an achievementchallenge.completedA user completed a challengeprestige.reachedA user ascended prestigefriend.addedA user added a friend
Endpoints
- GET /api/public/health · liveness
Manage webhooks
Create, rotate secrets, and pick events at /webhooks.