client SDK
JavaScript feature flags
featureflow-client runs in the browser. It fetches already-evaluated values for one user and caches them in localStorage. Version 2.x targets modern browsers. React apps should use the React client. Node servers should use featureflow-node-sdk.
JavaScript docsGitHubfeatureflow-client
Set it up with your coding agent
Paste this into Claude Code, Cursor or any coding agent. It installs the JavaScript SDK, creates the client and evaluates your first flag.
Set up Featureflow with the JavaScript SDK in this project. Run `npx skills add featureflow/featureflow-skills --skill featureflow-setup -y` first, then follow the skill. Keep SDK keys in env vars.
Or set it up by hand
Install
npm install --save featureflow-client<script crossorigin="anonymous" src="https://unpkg.com/featureflow-client@2/dist/featureflow.umd.min.js"></script>Initialise
import Featureflow from 'featureflow-client';
const user = {
id: 'user-123',
attributes: { tier: 'gold', country: 'australia', roles: ['beta'] },
};
const featureflow = await Featureflow.init('sdk-js-env-YOUR_KEY', user);Evaluate a flag
const checkout = featureflow.evaluate('new-checkout');
if (checkout.isOn()) {
showNewCheckout();
} else {
showLegacyCheckout();
}Kill switch
evaluate('new-checkout').isOn() is the check. A flag that has not loaded reads as off, so make off the safe state. defaultFeatures only applies with offline: true, which is useful in tests. Create the client once. A second init on the same page sends duplicate impression events.
The operational side is the kill switch. Turning the flag off does not require a redeploy.
Gradual rollout
Percentage rollouts bucket on the user id. If you omit the user entirely, each page load gets a new random anonymous id. Pass a user object with an empty id to get a persistent anonymous id, stored in localStorage and in an ff-anonymous-id cookie unless useCookies is false. Use your account id for signed-in users via updateUser(). evaluate() does not take a user. There is one user per client.
See progressive rollout for the dashboard control. Release pipelines and approval workflows, if the change itself needs a review, are on the Business plan at $399 a month. That price is on the pricing page.
Targeting
Put attributes on the user you pass to init or updateUser. Rules in the dashboard match them. await featureflow.updateUser() with no user switches to a new anonymous user. From version 2.2.0, jsonValue() reads a variant's JSON config or returns undefined.
Frequently asked questions
What is the JavaScript feature flags package?
featureflow-client. Import it as import Featureflow from 'featureflow-client'. Without a bundler, the UMD build is unpkg.com/featureflow-client@2/dist/featureflow.umd.min.js and exposes a global Featureflow.
Does evaluate() take a user?
No. evaluate(key) is synchronous and uses the user passed to init. Change that user with updateUser(), which re-evaluates every flag.
Which key do I use in the browser?
A client key starting with sdk-js-env-. It is public by design. A server key does not belong in browser source.