@oai-statsig/react-bindings
v4.0.0
Published
Statsig helps you move faster with feature gates (feature flags), and/or dynamic configs. It also allows you to run A/B/n tests to validate your new features and understand their impact on your KPIs. If you're new to Statsig, check out our product and cre
Keywords
Readme
Statsig helps you move faster with feature gates (feature flags), and/or dynamic configs. It also allows you to run A/B/n tests to validate your new features and understand their impact on your KPIs. If you're new to Statsig, check out our product and create an account at statsig.com.
Getting Started
Read through the Documentation or check out the Samples.
Packages
Clients
Product Bundles
Framework Specific Bindings
On-device and serverless DCS v2 migration
Version 4.0.0 is a breaking release for on-device and serverless clients. Upgrade
any directly installed @oai-statsig/* packages together to the same version.
On-device and serverless clients require full JSON DCS v2 snapshots. The default
download endpoint is https://statsigcdn.openai.com/v2/download_config_specs;
there is no v1/v2 version option. Explicit URLs, API overrides, and fallback URLs
are preserved and must return v2. SDK keys are sent in the DCS request header.
Before upgrading, publish v2 data to the KV key, Edge Config item, or bootstrap source selected by each application. The SDK does not choose an edge storage key. V1 network, bootstrap, custom-adapter, and stored payloads are unsupported. Inputs use the existing lightweight JSON parsing without full schema validation. Keep v1 edge values available for older SDK consumers during the rollout.
The default adapter stores the original v2 JSON under a separate specs-v2 cache
namespace. Existing v1 caches are ignored; the first initialization needs v2
bootstrap data or a successful fetch. getContext().values now exposes the v2
maps and condition references and can be passed back as v2 bootstrap data.
DownloadConfigSpecsResponse now describes that v2 wire format. The evaluator
uses the name-keyed spec maps, shared condition references, and numeric membership
records directly without expanding or rewriting the snapshot. Initialization
without any usable snapshot reports success: false and source NoValues.
initializeFromKV and initializeViaURL keep their selected source for later
async updates, prefetches, and any explicitly enabled background cache refreshes.
An empty or failed read does not switch to the Statsig CDN. Caller-provided
adapters retain control of their own refresh behavior.
For a direct on-device integration with Vercel Edge Config, configure the source on the adapter before initializing the client:
const dataAdapter = new StatsigSpecsDataAdapter();
dataAdapter.setDataSource(async () => {
const specs = await edgeConfigClient.get(edgeConfigItemKey);
return specs == null ? null : JSON.stringify(specs);
});
const client = new StatsigOnDeviceEvalClient(sdkKey, { dataAdapter });
await client.initializeAsync();
// Subsequent updateAsync() calls read the same Edge Config item.Community
If you need any assistance or just have a question, feel free to reach out to us on Slack.
