Skip to main content

Overview

Evaluation never throws. Missing snapshot → defaults.

createClient

Options

string
required
Environment-scoped SDK key (shipd_sdk_server_… or shipd_sdk_client_…).
string
required
Data-plane origin, e.g. https://edge.useshipd.com.
PartialDefaults
Per-key fallbacks used before a snapshot exists and for unknown keys.
EvaluationContext
Default { userId, attributes, segmentIds }.
number
default:"30000"
Poll interval. 0 = fetch once.
number
default:"5000"
How long ready() waits. Resolves on success, bootstrap, or timeout — never rejects for network errors.
number
default:"10000"
Per-request HTTP timeout. 0 disables.
FlagSnapshot
In-memory snapshot until the first successful fetch.
(error: unknown) => void
Fetch / schema / stream failures.
boolean
default:"true"
Batch to POST /sdk/v1/events.
number
default:"50"
Flush when the buffer reaches this size.
number
default:"5000"
Flush interval. 0 disables timer flush.
SnapshotCache
Durable cache. Browser default is localStorage.
string
WebSocket gateway origin (https://ws.useshipd.com). Omit for polling only.
boolean
default:"true"
After identify(), GET /sdk/v1/identity and merge under session traits.
string
Stable anonymous id. Browser generates one if omitted.
Browser-only (shipdit/client): persist (default true), storageKey, anonymousStorageKey (default shipdit:anonymousId).

Client methods

EvaluationContext: { userId?, attributes?, segmentIds? }.

Polling + stream

  1. GET /sdk/v1/snapshot (If-None-Match)
  2. Optional ws(s)://…/sdk/v1/streamsubscribe with environmentId + lastKnownVersion
  3. On snapshot.updated / snapshot.resync, refetch with minVersion retries
  4. Polling stays on
Reconnect: 1s → 2s → 4s → … → 60s + jitter, reset after a successful connection. Ignore snapshot bodies with version < local. Gaps fetch current only.

React

Call once in a client-only module. Hooks re-render on snapshot apply and identify / reset.

Versions

Guides: Evaluate · Target · React.