TypeScript SDK (@habifybase/sdk) & Official MCP Server (@habifybase/mcp)
Use HabifyPublicClient, HabifyServerClient, React Billing Kit components (<PlanPicker/>, <WalletTopup/>), dual-secret webhook verification, and 5 @habifybase/mcp IDE tools.
Last updated: 2026-11-24
1. Install & Initialize Browser vs Server Clients
HabifyPublicClient accepts hb_pk_* keys for React and Next.js client code. HabifyServerClient enforces server-only execution and throws SECRET_KEY_BROWSER_FORBIDDEN if bundled in browser code.
ts
import { HabifyPublicClient, HabifyServerClient } from "@habifybase/sdk";
export const habifyPublic = new HabifyPublicClient({
apiKey: process.env.NEXT_PUBLIC_HABIFY_PUBLISHABLE_KEY!,
projectSlug: "acme-app",
accessToken: () => currentUserJwt,
});
export const habifyServer = new HabifyServerClient({
apiKey: process.env.HABIFY_SECRET_KEY!,
baseUrl: process.env.HABIFY_BASE_URL!,
});2. Query Data API & Dual-Secret Webhook Verification
Use the fluent query builder for RLS-enforced CRUD, and verify inbound webhooks using verifyWebhookSignature() with built-in 24h rotation grace (v1 + v1_prev).
ts
import { verifyWebhookSignature } from "@habifybase/sdk/webhooks";
const valid = verifyWebhookSignature({
rawBody,
signatureHeader: req.headers["x-habify-signature"] as string,
secret: process.env.HABIFY_WEBHOOK_SECRET!,
previousSecret: process.env.HABIFY_WEBHOOK_PREV_SECRET,
toleranceSeconds: 300,
});