Prerequisites
- A GrowthBook account (cloud or self-hosted)
- An SDK Connection key — create one under Settings → SDK Connections in the GrowthBook UI
- The API host:
- Cloud:
https://cdn.growthbook.io - Self-hosted: your own GrowthBook URL (e.g.
https://growthbook.example.com)
- Cloud:
Why Use OpenFeature with GrowthBook?
OpenFeature defines a vendor-neutral interface for evaluating feature flags. Using a GrowthBook OpenFeature provider means:- Vendor portability — Your flag evaluation code is identical regardless of which provider is active. Switching from or to GrowthBook only requires changing the provider bootstrap, not a single flag call.
- Standardized API — Teams use the same OpenFeature interface they already know across all services.
- Ecosystem compatibility — OpenFeature-aware tooling — including OpenTelemetry hooks and other instrumentation — works automatically with GrowthBook.
- Polyglot consistency — The same conceptual API spans JavaScript, Python, Go, .NET, Java (and more), giving teams a single mental model.
Installation & Setup
- JavaScript
- Python
- Go
- .NET
- Java
Use
@openfeature/growthbook-provider with @openfeature/server-sdk in Node.js. Use @openfeature/growthbook-client-provider with @openfeature/web-sdk in the browser. The two providers are not interchangeable — either one throws if you register it with the wrong SDK.Both packages are published from open-feature/js-sdk-contrib and are currently pre-1.0. Report issues there rather than on the GrowthBook repos.- Node.js (server)
- Web (client)
GitHub: js-sdk-contrib/providers/growthbook | npm: @openfeature/growthbook-providerRequirements: Node.js 20+ (set by the current The provider reads global attributes once, when it initializes. Pass them as the second argument to
@openfeature/server-sdk)setProviderAndWait as shown above — calling OpenFeature.setContext() later does not update them on the server SDK.Evaluation Context (Targeting Attributes)
Pass user attributes to the OpenFeature client via anEvaluationContext. These become GrowthBook targeting attributes used for percentage rollouts, feature targeting rules, and experiment bucketing.
GrowthBook buckets users on the id attribute by default. The Python, .NET, and Java providers map the OpenFeature targetingKey to id for you. The JavaScript and Go providers do not — they pass the context through unchanged, so you must set id yourself.
Additional attributes (e.g. country, plan, email) are matched against your feature flag targeting conditions.
The JavaScript examples use the Node.js server SDK, which accepts an invocation-level context. On the web SDK, call await OpenFeature.setContext(context) instead of passing context into each evaluation.
Evaluating Feature Flags
OpenFeature defines five value types. GrowthBook’s feature flags map to all of them. The JavaScript examples below use the Node.js server SDK, where evaluations are asynchronous and take an invocation-level context. On the web SDK the same calls are synchronous and take no context argument — they read the global context set viaawait OpenFeature.setContext(...):
The JavaScript providers return GrowthBook’s own
source string as the evaluation reason (e.g. experiment, force, defaultValue) rather than the standard OpenFeature reasons such as TARGETING_MATCH or STATIC. Code that branches on details.reason is not portable across providers.Boolean
The most common type — use for on/off feature gates.String
Use for multi-variant flags where the value is a string (e.g. button color, layout variant).Integer & Float/Double
Use for numeric feature values such as rate limits, timeouts, or pricing.Object
Use for structured feature values (e.g. configuration payloads, theme objects).Configuration Options
* In JavaScript,
cache_ttl lives on the provider’s optional second argument as { cacheSettings: { staleTTL: 60000 } } rather than in the client options object. Every other JavaScript option in this table goes in the client options object.
Shutdown & Cleanup
Always shut down the provider when your application exits to close background connections.Further Reading
- OpenFeature specification — the full standard
- GrowthBook on the OpenFeature ecosystem
- Native GrowthBook SDKs — for Sticky Bucketing, Visual Editor, SSE streaming, and more

