Skip to main content

Overview

Jordan wires Fieldkit’s API to shipd. Flag checks are in-memory. The network is only for downloading the snapshot (evaluation payload) and optional realtime invalidation. This guide uses the flags from Define flags in code.

Install

Create a server SDK key in the dashboard. It looks like shipd_sdk_server_… and is shown once.

Server (Node, workers)

src/lib/shipd.ts
src/checkout.ts
ready() never rejects for network errors. On timeout it resolves anyway and you serve defaults until a snapshot arrives.

Browser

src/lib/shipd-browser.ts
Browser clients persist the last good snapshot (and a stable anonymousId) in localStorage unless you pass persist: false.
Client and server keys currently receive the same targeting rules. Prefer server keys for backends. Client keys are safe to embed; reduced client snapshots come later.

Context on a check

Without userId, percentage rollouts cannot bucket — the user falls through. Set a default identity with identify.

Polling and realtime

  1. GET /sdk/v1/snapshot with If-None-Match
  2. 200 — replace the in-memory snapshot
  3. 304 — keep it
  4. Optional WebSocket streamEndpoint/sdk/v1/stream → on snapshot.updated, refetch
  5. Poll every refreshIntervalMs (default 30_000) even if the socket is up
Omit streamEndpoint for polling only. refreshIntervalMs: 0 fetches once. If the edge is unreachable, the last good snapshot (or defaults) stays. Evaluation never throws.

Failure modes

Next