Your coding agent can add targeted feature flags and percentage rollouts to a TypeScript or React project without a GrowthBook account or client key. Give it the local flags guide, and it defines each audience and rollout in a checked-in flags.ts file. The open-source GrowthBook SDK evaluates those rules inside your app.
A checkout rollout, defined in code
Say you want a new checkout for 20% of UK shoppers on Safari who have a user ID. Your app supplies each shopper's country, browser, and ID. The rule sets the audience, the percentage, and the ID that keeps each shopper's assignment stable:
The condition values assume the strings your app passes. Each eligible shopper gets the same checkout on repeat visits. Raising coverage to 0.5 keeps the original 20% in the rollout. The rollout skips shoppers without a userId, so they see the default. The launch post on free feature flags for coding agents walks through this example in more detail.
What TypeScript checks
JavaScript and React SDK 2.1.0, published November 16, added the Register interface. You declare your feature, attribute, and event types once, and every GrowthBook instance and React hook is typed without generics. The LocalFeatures annotation checks flags.ts against the same types. The compiler then rejects:
- Misspelled flag keys, such as
newChekout. - Values of the wrong type, in rules and in-code fallbacks.
- Conditions on attributes you haven't declared, or values outside an attribute's type.
- A new instance that's missing a required attribute.
- Event names and properties in
logEventcalls that don't match a registeredeventstype.
Versions and limits
The guide's flags.ts needs SDK 2.2.0 or later, which both packages published on November 18. A local file also has the limits of any flag defined in code:
- Changing a rule takes a commit, a build, and a deploy, so there's no instant kill switch.
- Only engineers can change flags, and there's no UI.
- You can't run or analyze experiments.
GrowthBook Cloud or Self-Hosted provides these when you need them.
Getting started
Install @growthbook/growthbook 2.2.0 or later, plus @growthbook/growthbook-react for React apps. Then give your agent the prompt at the top of the local flags.ts guide. It asks the agent to create flags.ts, read every flag through the SDK, and report how it verified each flag.