Switchboard

1. Install the zero-dependency evaluator

Switchboard ships native ESM with strict TypeScript definitions and no transitive packages.

Terminal
npm install @switchboard/edge

2. Evaluate flags deterministically in memory

Pass your compiled edge snapshot and request context. Evaluation executes synchronously with zero network I/O.

worker.ts
import { createEvaluator } from "@switchboard/edge";
import snapshot from "./switchboard.snapshot.json";

const flags = createEvaluator(snapshot, { verifySignature: true });

export default {
  fetch(request: Request) {
    const userId = request.headers.get("x-user-id") ?? "anonymous";
    const enabled = flags.bool("checkout_v3_flow", {
      key: userId,
      region: request.headers.get("cf-ipcountry") ?? "US",
    });

    return Response.json({ checkoutV3: enabled });
  },
};

3. Declare automated rollback thresholds

Commit guardrail policies alongside application code so every rollout stage verifies error budgets.

switchboard.hcl
flag "checkout_v3_flow" {
  rollout = 35
  salt    = "sb_9042_v3"

  guardrail "checkout_5xx" {
    metric     = "http.checkout.5xx_rate"
    max_value  = 0.004
    window     = "60s"
    on_breach  = "rollback_previous_snapshot"
  }
}