Overview
Use the browser SDK (shipdit/client) for flags whose evaluated values are safe to expose to anyone with your public client SDK key. Evaluate flags on your server (shipdit or the Go SDK) when targeting depends on verified identity, role, or billing plan, or when flag values should stay private. You can combine both in one app, and neither replaces backend authorization.
What each SDK exposes
Server and browser SDKs use different credentials and receive different data from the edge.
A server snapshot contains your full targeting configuration—rules, audience predicates, rollout percentages, and every variant value. Keep server SDK keys and snapshots on infrastructure you control. Never serialize a server snapshot into browser HTML or pass it to a client.
A browser SDK never downloads a snapshot, so targeting rules, audiences, unused variants, and server-only flags (
clientAvailable: false) stay off the user’s device. However, a client SDK key is still a public credential: anyone who extracts the key from your bundle can call POST /sdk/v1/evaluate with any userId, attributes, or segmentIds they choose and read the resolved value (including any JSON payload) for every flag marked clientAvailable: true.
Choose where to evaluate a flag
Many applications use both patterns together: the browser SDK with
stream: true drives public UI presentation flags with realtime updates, while an authenticated backend endpoint delivers private evaluated values.
Deliver privately evaluated values to your frontend
When a frontend needs the result of a server-only flag, evaluate an explicit allowlist of flags on your backend and return only the resolved values—never the raw snapshot or targeting rules.1. Evaluate allowlisted flags with verified server identity
DeriveuserId, organization membership, role, and plan from your authenticated session and database. Ignore targeting attributes sent in the request body or query string, and disable HTTP caching with Cache-Control: no-store.
src/routes/capabilities.ts
2. Keep private values updated in the browser
Pair initial loading with polling, and add an authenticated Server-Sent Events (SSE) invalidation stream when you want realtime updates:- Initial fetch or SSR props. Load the evaluated values after authentication completes.
- Polling fallback. Refetch
/api/capabilitiesperiodically (for example, every 30 seconds) or on window focus. - Realtime invalidations (optional). Run your server SDK client with
stream: true, subscribe withshipd.subscribe(...), and push an empty invalidation event over an authenticated SSE route (Cache-Control: no-store). When the browser receives the event, it refetches/api/capabilities.
src/routes/capabilities-stream.ts
src/lib/use-capabilities.ts
/api/capabilities to re-verify authentication, organization membership, role, and plan.
Flags do not replace backend authorization
Flags control feature rollout and UI exposure, not permissions:- Browser flags are untrusted. Any user can inspect your bundle, spoof evaluation context, or call your API directly without going through hidden UI.
- Authenticated capability endpoints only inform the UI. Returning
{ auditLog: true }from/api/capabilitiestells the browser what to render; it does not protect the underlying API route. - Enforce authorization on every backend handler. Check authentication, role/RBAC permissions, tenant membership, and billing entitlements on every read and mutation endpoint. If a backend feature is also behind a release flag, evaluate the server-only flag in addition to—never instead of—your authorization checks.