Skip to content

SDK Reference

The runtime SDK evaluates flags locally, in-memory. Flag checks take microseconds and never touch the network. If the service is unreachable, the SDK returns your default values — your app never breaks because of us.

Terminal window
pnpm add @shipdit/sdk
import { createClient } from "@shipdit/sdk";
const flags = await createClient({
sdkKey: process.env.YOURFLAGS_SDK_KEY!,
});
// Boolean flags
if (flags.isEnabled("my-first-flag")) {
// new behavior
}
// Variant flags (type-safe from generated types)
const variant = flags.getVariant("search-variant");
// ^? "control" | "semantic" | "hybrid"
// With evaluation context (required for targeting rules)
flags.isEnabled("beta-feature", {
userId: user.id,
plan: user.plan,
});

Every evaluation accepts an implicit or explicit default. The SDK never throws on a flag check:

  • Service unreachable → default returned
  • Flag not found → default returned, warning event reported
  • Malformed update → last known good state retained
await flags.close(); // flushes analytics, closes connections

Coming soon: @shipdit/react.