Quickstart
Install the SDK, create a flag and run your first experiment in about ten minutes.
This guide takes you from nothing to a running experiment. You need a Kerf project and a server or browser app where you can install a package.
1. Install the SDK
npm install @kerf/js2. Initialize
Create one client for your app and reuse it. The client downloads your rules once and evaluates locally, so each decision runs in under 1 ms and makes no network request.
import { Kerf } from "@kerf/js";
export const kerf = new Kerf({
sdkKey: process.env.KERF_SDK_KEY,
});
await kerf.ready();3. Identify a user
Every decision needs a stable user id. Add attributes you want to use in targeting rules.
const user = {
id: "user_8421",
plan: "pro",
country: "DE",
};4. Check a flag
if (kerf.flag("new-checkout", user)) {
renderNewCheckout();
} else {
renderOldCheckout();
}5. Create an experiment
In the dashboard, open the flag and choose Add experiment. Pick a primary metric, set the split to 50 and 50, and choose a guardrail. Kerf logs an exposure event the first time a user is evaluated.
6. Read the result
- Open Experiments and select your test.
- Wait until the sample size estimate is reached.
- Check that the sample ratio status is healthy before reading the result.