Best platforms for A/B testing AI features

A team testing a document assistant changes its retrieval prompt. The candidate wins on the evaluation set, produces shorter answers, and uses fewer output tokens. After a small rollout, more customers ask the assistant to try again. Is it doing the same work more cheaply, or shifting work onto the customer?
A live A/B test can answer whether the change improves the product experience for eligible users. To do that, the platform needs to preserve who was assigned, which system actually served the request, and what the customer accomplished afterward. A trace can reveal that a model timed out. A randomized comparison can estimate how often customers complete their work when the product adopts the new policy, including what happens after that timeout. Buying a tool with “AI” on its pricing page tells you little about its ability to connect those records.
Choose a platform around the evidence you can recover
| Platform | When to shortlist it | Decisive proof of concept |
|---|---|---|
| GrowthBook | Model telemetry and customer outcomes can be queried in the warehouse, and engineers need to control rollout and measurement | Join an assigned user to successful and failed tasks, then reconcile revenue, latency, and cost against source rows |
| Statsig | A product team wants feature delivery and experimentation in the same SDK workflow | Reproduce one experiment exposure through an actual configuration read and calculate the bill for the planned event volume |
| LaunchDarkly | An organization already governs software releases through flags and needs to test model or prompt configurations | Demonstrate a fallback, a metric event, and the evidence that connects both to the original assignment |
| Datadog Experiments (formerly Eppo) | An experimentation team wants its existing warehouse measures to drive a live product decision | Trace an assignment and a delayed customer outcome from the proposed integration to the analysis |
These platforms can complement an offline evaluation system. Give researchers a stable benchmark for structured correctness and have product engineers measure actual task completion after release. Ask the platform vendor which part it handles and where another system needs to take over. A platform can be a sound purchase if it answers one of those questions well and your team already has a dependable answer to the other.
Define a treatment that survives retries
For a document assistant, write down the complete policy that can change the user's experience. It might include a retrieval configuration, a prompt revision, a maximum output length, a model identifier, and a fallback. Save those choices under a version your team can reconstruct. If control uses the established configuration while treatment uses new retrieval and a different model, the estimated effect applies to the combined policy. Separate the changes into subsequent tests if the eventual decision requires you to pick one.
Follow one request through the system. A user assigned to the candidate may get a response from the baseline model when the first attempt times out. Keep both records. The assignment tells you what policy the user entered. The request trace explains why the response came from a different route. Moving the user into control after the timeout would give treatment credit for its successes while sending its failures to the other arm. A fair business comparison generally keeps them in the assigned arm and uses the route as diagnostic evidence.
Select outcomes at the level of the decision
Suppose a user asks for a comparison between two lease drafts. A high model score, a fast first token, and a click on Copy are reasons to inspect the interaction. The product decision may depend on whether the user completed the comparison without opening a support ticket or redoing it manually. Pick an observable outcome at the level you intend to improve. If the product promises faster work, measure elapsed time to a completed task, including retries and fallbacks. Define what happens when a user leaves and never completes it.
Also ask which data you can omit. For a comparison of retrieval strategies, a stable assignment ID, a configuration revision, an error category, elapsed time, and a durable completion event can answer several initial questions. Full uploaded contracts carry a very different privacy and retention obligation. The OpenTelemetry conventions for GenAI token metrics illustrate how to record usage measurements separately from text content. Decide what evidence you need before proposing that every trial log every prompt.
GrowthBook for teams that measure AI in their warehouse
Where it fits
Choose GrowthBook when the model call is just one step in a workflow and the trustworthy outcome lives elsewhere. A support agent might ask an assistant for a suggested reply, edit the draft, send it, and later reopen the case. The trace tells you that text was generated. A customer-support system tells you whether the problem stayed resolved. GrowthBook's experiment analysis can use warehouse data to connect assignment to those downstream outcomes. That makes it a good starting point when departments already share definitions for case resolution, refunds, or subscription retention.
Start the trial with a representative user who gets treatment, sees a model error, and resolves the case manually. Can the analyst recover the original assignment and count the resolution under the agreed outcome definition? Can the engineer explain the error and its cost without changing which arm owns the user? You need the error and the resolution separately to distinguish a more effective assistant from a more capable human support team.
Strengths for governing model changes
An experiment flag can choose a versioned policy at the point where a service decides which model configuration to invoke. A/B testing through feature flags gives the engineer a way to deliver both paths while control and treatment share the rest of the application. Capture the assigned variation before invoking a provider that can fail. If the service retries, preserve the original task ID and assignment while giving each model request its own diagnostic record.
GrowthBook's LLM trace integrations can bring trace-derived measures into a warehouse-based experiment analysis. During the proof of concept, use a known task with two inference attempts. Check that the task outcome counts once while both billable requests contribute to the cost. Ask the data team to repeat the analysis with one missing trace. That reveals whether the reporting query quietly drops users who generated no diagnostic records. The data team still owns the join, the metric definition, and the response to incomplete coverage.
When a ranking comparison calls for a different experiment
If your feature ranks documents, an interleaving design can sometimes compare the relative preference for two rankers within a shared result list. GrowthBook supports team-draft interleaving for ranking experiments. That is a particular design for ranked items and attributable interactions. A single generated legal summary does not turn into a list-ranking experiment just because an LLM produced it. Even for rankers, a preference signal from clicks and a downstream business measure such as successful resolution can point to different decisions.
Pricing and operational watchouts
GrowthBook lists its Cloud and self-hosted plans separately. Check the plan features you need, the seat count, the selected warehouse, and access to the controls the release owner wants. Include provider inference spend and warehouse query spend in the trial budget. A platform fee can stay constant while a treatment triples the number of requests per completed task. If the relevant data sits across multiple environments, use a technical demo to trace one source row all the way to the analysis before you commit.
Connect evals to a live test
See how an offline check and a randomized comparison answer different questions about an AI feature.
Read the AI Evaluation GuideStatsig for testing prompt versions against product outcomes
Where it fits
Statsig is worth shortlisting when one team owns the prompt and another team owns the decision to release it. The first wants to compare responses on known examples. The second wants evidence that the change helped people using the product. In Statsig Agent Experimentation, a config contains the prompt, model, and parameters for an LLM task. From a config with at least two Live or Candidate versions, a team can create an experiment. Statsig places it in the config's layer, gives each version a group, and initially splits traffic evenly. The application fetches the configuration at runtime.
Consider an assistant that extracts action items from a customer meeting. The existing prompt favors short tasks. A candidate adds the responsible person and a source sentence to each suggestion. In development, give both prompts a transcript containing one clear commitment, one tentative idea, and one canceled assignment. Inspect the treatment's extra detail. An assistant that confidently assigns the tentative idea to a person has made its output more specific and less useful. That fixture earns its place in the release process even if the real product question is whether users complete more of the right follow-up work.
What to ask the evaluator to prove
A grader can check whether cited sentences exist in the transcript. A human familiar with the discussion may be needed to decide whether a statement was a commitment. Select the method that matches the judgment. Anthropic's work on code-based, model-based, and human graders explains why an exact structural check and a review of task success can contribute different evidence. In a buyer trial, ask a teammate to change the grader's rubric without changing the candidate prompt. The resulting score can move even when users see exactly the same output. Save both versions so the readout can identify what changed.
There is a product detail to verify before trusting an empty chart. For experiments created from a config, Statsig's automatically added evaluator metrics average scores your code records through logEvalGrade. Automatic online grades are recorded separately and do not feed those experiment metrics. Send one known sample through the intended path, inspect the event and evaluator name, and identify where it appears. Give the team a second criterion based on user behavior, such as the proportion of eligible users who save a correctly attributed action item to their work list within a day.
Keep assignments attached to the delivered answer
Decide who should receive a consistent assistant. If attendees share one meeting summary, assign at the meeting or workspace level as the product requires and account for that unit in the analysis. Otherwise two attendees could discuss different versions of supposedly shared notes. Retain a config version, a generation identifier, the assignment key, and the actual model used. When the provider times out, preserve the original assignment even if the application falls back to another model. A procurement demo using only successful outputs skips the exact path most likely to change both cost and customer experience.
Try an uneven workload before buying. Give one test workspace a long meeting that produces four model calls, and three other workspaces short meetings that each produce one. Count workspaces, completed summaries, and model calls separately. A per-generation success rate will give the long meeting more influence. A per-workspace metric asks whether a typical workspace got a usable result. The unit that matches the release decision should appear in the headline, with the rest available to explain it.
What drives the bill
Statsig's hosted pricing meters activities including qualifying experiment exposures and logged events. Model calls for previews, offline runs, and LLM judge evaluations use included credits or a project's own provider keys according to the Agent Experimentation setup. Estimate metered events and model usage separately. For example, a sample of a thousand output grades can be inexpensive against short answers and materially more expensive against long transcripts if the judge sees that context.
Have the evaluation owner estimate a week that includes a repeat of the offline suite and a live experiment. Count each production generation, the subset sent to a judge, and any repeat attempts. Identify who receives the provider invoice for each. That exercise gives you a credible cost for the team's normal development cycle and distinguishes it from the cheap first run in an empty project.
LaunchDarkly for teams managing AI releases alongside feature flags
Where it fits
LaunchDarkly's AgentControl is a candidate when prompt, model, or routing changes go through the same release process as other application changes. A team can define config variations for competing AI behaviors and use LaunchDarkly Experimentation to compare them for a chosen context. It is a different decision from turning on a candidate for internal employees and watching a latency chart. The randomized experiment needs an eligible audience, a consistent unit, and an outcome people can experience under either variation.
A useful trial is a support assistant that drafts replies for human agents. The proposed route uses a faster model for straightforward requests. For the experiment, keep a stable assignment for each agent if they work independently and might learn the interface across tickets. If agents share a queue and reuse each other's drafts heavily, investigate assigning by team instead. In either case, the product outcome might be resolved tickets that stay closed for a defined period. A fast draft that triggers more follow-ups can be an expensive improvement.
Compare the intended route with the observed route
Select several representative tickets and follow each one across the router, retrieval service, model provider, and editor surface. The W3C Trace Context standard specifies identifiers for connecting spans across services. A trace can explain one request while the experiment assignment preserves the unit used in the statistical comparison. Give the trial operator both identifiers. They should be able to answer why a ticket assigned to the faster route ultimately used the original model without changing which group gets credit for the customer's experience.
Record time to first useful content, generation duration, and total time until the agent can edit the draft. These can diverge when the output streams quickly but an application waits for citations before enabling editing. The OpenTelemetry generative AI metric conventions give instrumentation teams a shared vocabulary for model timing and usage. Instrument the editor boundary separately. A provider's fast response is one component of the experience.
Establish what a quality score will change
LaunchDarkly supports online judges for AgentControl configs. For completion-mode variations, teams can attach built-in judges for accuracy, relevance, and toxicity and use evaluation metrics as experiment goals. Judge calls run from the application with its configured provider. Pick a team-specific question that justifies the additional scoring. A response can be relevant and courteous while offering a refund that the customer cannot receive. A small set of human-reviewed tickets can help distinguish a useful rubric from one that rewards agreeable wording.
During the trial, deliberately withhold a judgment for one failed generation. Inspect the report to see how many eligible tickets, successful generations, and completed evaluations it includes. A mean score over judged successes can rise if the most difficult cases fail earlier and disappear from its denominator. Keep the failure rate and coverage visible. Ask the release owner what they would do if judges preferred the candidate while agents spent longer correcting its drafts. The two measures can disagree legitimately, and a platform needs to surface that disagreement.
Price a generation, a judgment, and a completed task
LaunchDarkly pricing defines an AgentControl AI run as a model call through a config or a judge evaluation. One generation plus one judge therefore consumes two runs, alongside any model-provider charges. If a pilot generates 8,000 replies and applies one judge to 10% of them, it produces 8,800 runs under those assumptions. Retries, additional agent steps, and a second judge can all alter the estimate. Verify the other relevant usage dimensions on your plan and compare the projected bill with the number of resolved tickets the assistant supports.
Datadog Experiments for teams evaluating Eppo
Where it fits
If Eppo is on your shortlist, evaluate its current product, Datadog Experiments. It fits a team whose operational signals already live in Datadog and whose important customer outcomes may arrive later in a warehouse. Picture a support assistant that drafts troubleshooting steps. Request latency becomes visible during the conversation. Whether the customer returns with the same problem may take a week. Both signals can inform a release, provided you can trace them to a consistent unit of assignment.
Start the trial with one support ticket that reopened. Ask an engineer to identify the prompt variant the customer actually received. Ask an analyst to find the later reopening in the case-management data. A request ID gives you the generation trace. A ticket or customer key gives you the longer journey. Decide how to handle one customer with several tickets and one ticket with several model calls. Otherwise a candidate that calls the model three times per reply can acquire more statistical weight simply by doing more work.
Choose the data path before configuring a test
Datadog documents distinct randomization and metric paths. Warehouse-native analysis supports Snowflake, BigQuery, Redshift, and Databricks. If you supply assignments from your own routing system using an Exposure SQL Model, you also need warehouse-native metrics. Alternatively, a client-side test using Datadog Feature Flags can use Real User Monitoring or Product Analytics events to measure behavior without querying a warehouse. Map those conditions to your architecture. Routing prompts inside a server-side service and recording outcomes in a support database is a different integration from changing a client-side interface.
The documentation also describes online experiments using Agent Observability as a preview that requires access. Request a demonstration with your account if that workflow is the reason you're evaluating the platform. A demonstration of an offline comparison on a curated set of past conversations answers a different question from a randomized comparison of how current customers fare. Have the person giving the demo identify the source of production assignments, the eligible population, and the delay before your chosen outcome appears.
Pricing and implementation questions
Datadog's Experiments pricing starts at $450 per launched experiment per month billed annually, or $575 on demand. A launched experiment becomes billable once it reaches 500 subjects and has 3 days of data. Ask for a quote that shows the experiment charge alongside any observability data and warehouse compute your proposed workflow uses. A budget based on calls to the model alone leaves out the units Datadog uses for its experiment product.
Bring two candidate tests to that conversation. One changes the default prompt for every support ticket. The other changes a specialist workflow used by a few hundred enterprise customers. They have different prospects of reaching the billing threshold and different prospects of detecting a useful change. Hitting the threshold establishes when the test is billable. Your baseline outcome rate, randomization unit, minimum effect of interest, and expected traffic establish whether it can answer the product question.
Compare a benchmark win with a customer outcome
A support assistant returns a correct troubleshooting step in a replayed ticket. That is evidence about the model's response to an input you selected. A customer uses the new assistant and resolves a problem without opening another ticket. That is evidence about the product experience, which includes waiting, reading, deciding whether to trust the advice, and acting on it. An experimentation platform should let the quality team investigate the first event and the product team measure the second.
Build the offline dataset from several sources. Include known regressions, a sample of ordinary requests, and tasks the new design claims to improve. Mark which examples informed prompt development and reserve a separate set for evaluation. Freeze the input, expected behavior, retrieval corpus version, and grading rule used in a comparison. For an agent that changes application state, inspect the final state as well as the text it returns. An assistant can say it scheduled a follow-up when no appointment exists. Anthropic's agent evaluation guidance makes the distinction between an execution transcript and the outcome of the task.
For the live test, give the analyst the assigned customer or ticket ID, the configuration actually served, and the trace ID. Record timeouts, fallbacks, and abandoned interactions. If the dashboard includes only traces that reached a final model response, it will overlook customers facing the most broken part of the experience. GrowthBook's LLM trace-to-metric workflow illustrates how telemetry can feed an experiment readout. The denominator still comes from the assignment design. Ten scored model calls from one ticket do not represent ten independently assigned customers.
Calibrate the judge on the mistakes you care about
Suppose the team wants an automated judge to flag answers that cite a troubleshooting step the product cannot perform. Define the failure in terms of observable evidence. A labeled answer either recommends an unsupported action or it doesn't. Give reviewers the same product references used for adjudication. Hide the variant and model names. Include some responses from both variants so a grader that prefers one writing style has a chance to reveal itself. Have two people label a subset independently and resolve disagreements before treating either label as ground truth.
Take a hypothetical calibration set of 100 reviewed answers. Human reviewers identify 20 unsupported recommendations. The judge flags 30 responses, 15 of which are among the human-confirmed failures. The resulting precision is 15/30, or 50%. Recall is 15/20, or 75%. It misses five known failures and sends fifteen acceptable answers to manual review. Its overall agreement is 80%. That last number alone tells the operator little about how many alerts they'll investigate or how much harmful advice will slip through.
Split those counts by task family and answer style. A rubric tuned on concise instructions might penalize a verbose but valid explanation. In pairwise judging, reverse the order of candidate answers and measure how often the preference changes. Researchers documented position and verbosity effects in MT-Bench and Chatbot Arena judge evaluations. Other researchers found that model-based scoring can favor LLM-generated text. Those findings justify checks on your grader. They don't predict the direction or size of bias for your support assistant.
Audit who supplies feedback
A thumbs-up rate can change because the audience changed, the output improved, or the feedback control became easier to find. Suppose control collects 70 positive ratings among 100 ratings from 1,000 assigned tickets. Treatment collects 120 positives among 200 ratings from 1,000. The positive share among raters drops from 70% to 60%, while positive feedback per assigned ticket rises from 7% to 12%. Neither comparison tells you how the 900 silent control tickets or 800 silent treatment tickets would have been rated.
Log whether the feedback control was shown, whether a rating arrived, and whether an independent task outcome exists for each eligible ticket. Sample silent tickets as well as rated ones for blinded human review. Preserve the sampling probabilities if you deliberately oversample failures and plan to estimate a population rate. Keep the enriched sample for debugging even when it cannot answer a prevalence question. A clean separation between learning where the system fails and estimating how often it fails will save the team from presenting a hand-picked audit as a customer-wide result.
Ask each finalist to export the response, rubric version, originating variant, and review result for a small set of synthetic tickets. Use the W3C data minimization principles to decide which fields your reviewers actually need. A source citation and a redacted answer might be enough to grade supported actions. Access to every customer identifier in the trace adds little to that task. Keep the assignment join available to the analyst who needs to reconcile the sampled reviews with the complete experiment.
Give the finalists the same copilot release decision
Your product has a copilot that drafts a response to a support ticket. The candidate version retrieves more account history before drafting. Offline reviewers like its answers. Finance expects a higher inference bill. The support lead has one question for both groups. Does the change help people resolve enough tickets to justify the extra work and cost? A useful platform trial ends with an answer that the support lead could act on.
Define a successful task with the people who own the workflow. For this exercise, count a distinct ticket once when a human reviews the reply, sends it, and the ticket stays resolved for seven days. A generated draft alone earns no credit. A retry on the same ticket can add cost without adding another success. Give the analyst the ticket ID, the assigned agent ID, the variation and version identifiers, and the costs of every associated operation. Use a stable event ID for each billable call so that a repeated analytics delivery doesn't double the bill. Conversely, keep two genuinely billable retries as two cost records.
Calculate what one additional success costs
Suppose 1,000 support agents are randomly assigned to each version for the same evaluation period. Follow their eligible tickets long enough to observe the seven-day reopening window. The existing copilot spends $180 on inference and retrieval and produces 1,000 successful tickets. The candidate spends $268.80 and produces 1,120. Cost per success is $0.18 for the existing version and $0.24 for the candidate. The candidate also delivers 1.12 successes per assigned agent, compared with 1.00 for control.
The expansion question calls for a different calculation. The candidate spent an additional $88.80 to deliver 120 additional successes. At these observed rates, each additional success cost $0.74. If an incremental durable resolution is worth $2 to the team after support labor, that looks promising. If it is worth $0.50, the same point estimates suggest a poor trade. Enter your team's own valuation, include downstream human review time where it differs, and keep the uncertainty visible. A difference of only a few successes can make the incremental cost estimate jump or even change sign. In that case, show the extra spend and extra successes separately.
Give each finalist the raw rows and the metric contract. Ask how it handles agents who see the feature but complete zero tasks, how it deals with tickets reassigned between agents, and who can verify the result from the underlying records. If reassignment is common, decide before launch whether ownership follows the initially assigned agent or whether randomization by support team is more defensible. An analyst should be able to explain what happens to those tickets in both the experiment and the cost report.
One agent may complete 25 tickets while another completes one. Treating 26 tickets as independent experimental units would overstate the information you gained from two assignments. Keep the user-level totals of spend and successes together when estimating uncertainty. A ratio of total spend to total successes also differs from the average of each person's cost per success, which is undefined for someone with no successes. The statistical literature on ratio metrics in online experiments gives methods for handling these relationships. Ask the vendor what its reported interval describes and whether your analyst can reproduce it by resampling assigned units.
Time the job the customer is waiting for
For a streaming interface, the first visible token can arrive quickly while the answer takes several more seconds to become usable. For a draft that requires citations, the decisive wait may end only when the evidence links appear and the Send button becomes available. Measure the interval from request to usable draft in the product. Keep the underlying model's time to first token and end-to-end request latency for diagnosis. Include cancellations and timeouts as separate outcomes. Dropping them from the latency chart can make a struggling variation look faster.
During the trial, provide a ticket for which retrieval times out, one for which the model responds twice, and one that the support agent resolves manually after abandoning the copilot. Ask to see what the platform counted in each case. The manual resolution might belong in an overall productivity metric even if the copilot receives no completion credit. A randomized study of experienced developers using AI on their own tasks illustrates why perceived speed and measured task completion time deserve separate measurements. Its results concern that particular study population. Your pilot needs evidence from your own support workflow.
Name the condition that would stop the rollout
If 10,000 distinct agents are eligible in a day, allocating 2% of them to a pilot that splits evenly would put about 100 agents on the candidate that day. That is an expected count. A percentage rule doesn't cap an individual's usage, so those agents could generate thousands of requests during a difficult incident. Forecast requests as well as people. Add a service-side limit on concurrent expensive calls if capacity requires a hard ceiling, and agree on the established response path when the limit is reached.
Rehearse a provider timeout with a teammate observing the product and another observing cost and error metrics. If disabling the candidate lets new tickets use the baseline, check what happens to a draft already in flight. Does it finish once, restart at the user's expense, or silently disappear? Google's canary release guidance describes the value of measuring a limited release against a comparable population before expanding it. The operator needs to know which signal warrants pausing the rollout now and which product outcome needs a full follow-up window.
Bring the support lead back for the readout. Give them the number of additional durable resolutions, the range of effects compatible with the data, the incremental spend, and the delay customers actually experienced. A platform that can connect all four quantities to a specific release gives that person evidence for a business decision. A platform that only reports a winning model score leaves the decision with the analyst who still has to do those joins.
Make one provider failure part of the final demo
Give each finalist the same test record. A user was assigned to the new policy. The first model call timed out, the fallback generated an answer, the user edited that answer, and the underlying task succeeded. Ask for the assigned variation, effective route, actual inference cost, and final user outcome. Then ask a product manager to find that same user's contribution to the experiment report. A good fit gives the PM an interpretable result while letting an engineer reconstruct the exceptional path.
For teams that already collect business outcomes and model telemetry in a warehouse, GrowthBook is the best fit on this shortlist. It gives software teams a release mechanism and data teams a way to evaluate the full customer workflow against published metric definitions. Start with one AI feature that has an independently verifiable outcome, and use it to prove the trace-to-business join. If another finalist fits the team's release controls or existing metric infrastructure better, hold it to the same failed-request test.
Ship the selected policy only after the evidence covers the declared population, guardrails, and effect size. Keep the previous configuration available for a deliberate fallback, and record the date of any model or retrieval change that would materially alter the experience being measured. That record is how the next team can tell whether it is extending a successful experiment or starting a different one.
Test one AI feature in production
Build a controlled comparison in GrowthBook using a customer outcome and cost measure from your own data.
Start Your AI ExperimentRelated Articles
A magazine's home page shows two recent issues. The design team wants subscribers to try a shelf with four. All four covers are public, and changing editions while the page is open should update the shelf immediately. That gives you a small React feature with a useful acceptance test. Click from guest to subscriber and back, and count the covers each time.
We'll put the display limit in a typed local flag, evaluate it inside a React component, and leave the choice of edition with the app. The example runs in a client-rendered React app without a GrowthBook account, an SDK key, or a request for flag rules. For the wider workflow, free feature flags for coding agents explains what to ask an agent to implement and how to review the result.
Define what one flag controls
Start with an existing React and TypeScript app, or create a Vite React project for the example. Install both GrowthBook packages so the definitions and the hooks resolve against compatible SDK versions.
Create src/flags.ts. Here the feature value is a number, which lets the component use the same rendering code for either edition. A future change from four covers to three is one edit to the rule.
A guest falls through to the default of two. A subscriber matches the rule and gets four. This rule applies to every subscriber, so the ID has no effect on the result here. If you later roll the shelf out to a percentage of subscribers, you already have an identity to use for repeatable assignment.
The type registration release note explains the version requirement for LocalFeatures. The registration connects the definition, the attributes, and the value returned by the hook. For the TypeScript mechanics, see Jeremy Dorn's Register pattern walkthrough.
Put the current reader above the shelf
Replace src/App.tsx with the component below. The edition switch is a local fixture so anyone reviewing the change can reproduce both states. In an existing app, take those two values from the active reader in your session layer.
The provider receives an instance initialized with the current reader and the checked-in rules. React can render the correct shelf on the first pass for that reader. If the app is still loading a session, decide what should occupy the shelf in the meantime. For this public list a two-cover guest view is reasonable. On a page where a switch would interrupt the reader, wait for the session before mounting the shelf.
Give your agent the React setup
Use the local flags guide to ask for a typed definition, a provider with the current reader, and a test that changes the edition.
Open the Agent GuideThe useMemo dependencies include the ID and the edition. If a reader subscribes while signed in, their ID can stay the same while their edition changes. Depending only on the ID would leave the old SDK instance in place. Passing a fresh object as the dependency on every render would create unnecessary instances. The example uses the two primitive values the rule setup actually needs.
Read the numeric flag where React renders the list
Create src/IssueShelf.tsx. Keep one stable ID per issue and let the component use the resolved value to select how many items to render.
Keep the hook at the top of the component, inside the provider's subtree. The React SDK supplies the flag value through that provider. Calling a hook inside a click handler or inside the list loop would break the Rules of Hooks. Use the returned number in ordinary render logic.
There are two places you can see the number two in this implementation. The definition's defaultValue is what an ordinary guest gets through evaluation. The 2 passed to the hook is a fallback for a value the SDK can't supply. Giving them the same value makes the basic shelf a sensible fallback, but checking only the guest case would let a broken provider arrangement or missing definition go unnoticed. The subscriber case proves that the component actually received the rule.
The list keys identify magazine issues. Keep those keys independent of the flag. Switching from two covers to four should preserve the identity of the first two rows. There's also no need to remount the whole app with an edition-specific key. React preserves state according to component position and keys. For example, a search input outside the shelf shouldn't lose its text because someone subscribed.
Check the transition in both directions
Use the template's build script to type-check and bundle the app. Once that passes, start the dev server and open the local address it prints.
On first load, the page says guest and lists November and October. Click Switch edition. The same page should say subscriber and add September and August. Click again. The list should return to the original two issues, in order. This last check catches code that appends more results on upgrade and never removes them on downgrade.
For a compile-time check, temporarily replace the numeric fallback with the string "2". Run the build again and inspect the error on the hook call. Then restore 2 and rebuild. If the string compiles, check that src/flags.ts belongs to the same TypeScript project as the component and that the package manager resolved compatible core and React versions.
Look for the core package used by your app and by the wrapper. If the app has several incompatible installations, align the versions before diagnosing the JSX. A team using an existing build script should also confirm it actually runs the TypeScript checker.
Hand off a React change someone can review
Give your coding agent the one-shot local feature flags guide and a short description of the observable behavior. For this shelf, the request can be as specific as the test.
The shelf controls how many public titles to display. If your actual feature unlocks paid articles, enforce access when the server serves an article. A client-rendered flag only decides what to show in that browser. Whenever a change to the display limit can wait for a deployment, the small local file keeps the decision reviewable alongside the component. When an editor needs to change it between issues without an engineering release, compare the free GrowthBook options for managing flag rules.
Manage the shelf in GrowthBook
Start a GrowthBook workspace when your magazine team is ready to manage shelf rules between deployments.
Get Started with GrowthBookTwo customers download the same weekly report. One has agreed to preview a new CSV column. The other feeds the old two-column format into an importer. Both requests can land on the same Node.js process, and each needs the right file even if the other request arrives while the report is loading.
This tutorial builds that endpoint with one checked-in feature flag. The process loads the rules once. Each request supplies its own workspace attributes and receives its own evaluation. You can run the whole example on your machine without an account, a client key, or a flag server. The free feature flags for coding agents walkthrough introduces the local approach. Here we'll give the agent a server-specific test to pass.
Set up a small TypeScript service
Use Node.js 22 or newer for this example. In an empty directory, create an npm project that uses ES modules, install the core SDK, and add the TypeScript tools.
Create tsconfig.json at the project root. The sample runs TypeScript directly with tsx and checks types in a separate step. Type checking with tsx explains why the two commands serve different purposes.
The following files all live next to that configuration. The server imports ./flags.js even though the source file is flags.ts. That spelling follows TypeScript's Node.js module resolution for ESM and works with this runner.
Define the report contract in one flag
Create flags.ts. The public format has two columns. The sample preview workspace gets one additional column. The only targeting attribute the rule needs today is reportPreview. Carry the workspace ID too, so two people downloading a report on behalf of the same workspace can share an assignment if you introduce a percentage rollout later.
The SDK type registration update covers this rule syntax and the 2.2.0 minimum. If you misspell reportPreview in a condition or use a string where the boolean flag expects a value, TypeScript can point at the definition. The Register pattern also makes the same feature name available in other modules without threading a generic type through each handler.
Before you add the endpoint, decide what belongs to the process and what belongs to the request. The feature definitions are identical for both customers. Their identity and preview enrollment can differ. If a handler changes an attribute on a single shared user instance before awaiting a database query, another handler could replace that attribute before the first handler resumes.
Give your agent a server-side task
Use the one-shot guide to add checked-in rules. Ask your agent to keep workspace attributes local to each request and demonstrate both CSV formats.
Open the Local Flags GuideCreate a scope when the request arrives
Create server.ts. The Node.js SDK provides GrowthBookClient for the process and createScopedInstance for the current request. The two fixture paths below stand in for two authenticated workspaces. The server binds to the loopback address so you can exercise it locally.
The HTTP handler looks up a workspace, creates its scope, and holds that scope across an asynchronous operation. The short promise-based timer gives a second request time to arrive. In a real export, that's where the database or storage read would happen. Keep the stable client at module scope and the scoped instance inside the handler. If a formatter needs the decision, pass it the boolean or the scoped instance.
In production, resolve the workspace and its access rights from the authenticated session before reading the report. The two selectable paths here are fixtures for public sample data. A caller's choice of a header, query string, or workspace slug can't establish permission to read another customer's report. The endpoint also prevents shared response caching. If you cache real exports, the cache needs to distinguish the workspace and the report format, along with any other inputs that change the response.
Test two requests that overlap
In the first terminal, type-check the service and start it. A successful type check exits quietly. The next command prints the loopback address and keeps the server running.
Save the following as verify.mjs. In a second terminal, run node verify.mjs. Node's built-in fetch calls the local server. Strict assertions compare the full header and data row, including where each row ends.
You should see the single success line. Testing just the preview workspace proves that the code can add a column. Testing both responses catches the more expensive mistake of silently changing an existing customer's export. Keeping the old format assertion around is especially valuable when the downstream importer belongs to someone outside your team.
To check the compile-time boundary, temporarily change gb.isOn("includeUniqueReaders") to gb.isOn("includeUniqueReader") and rerun npx tsc --noEmit. The diagnostic should identify the misspelled key. Restore it before running the server again. A coding agent can include the before-and-after type check and the two CSV headers in its pull request.
Decide when to expand the report
When one preview customer is ready, leave everyone else on the default. If the next step is to enroll a fraction of workspaces, choose an attribute that matches the promise you're making. Hashing a workspace ID lets colleagues downloading the same report share a format. Hashing each user's ID could give two analysts in the same company different column sets. The one-shot guide shows how to express a percentage and hash attribute in a local rule.
A new rule in flags.ts reaches a process through your deployment. During a rolling deploy, the same workspace might hit old and new processes. If customers need a durable choice of export schema, keep supporting the agreed format in the API itself. When the operational requirement is to change targeting between deploys, you can keep the scoped evaluation in the handler and change how the process receives its rules. The free GrowthBook offerings overview covers Cloud Starter and self-hosting for teams that want to manage those rules.
Manage report targeting in Cloud
Create a GrowthBook workspace when the team supporting exports needs to expand the preview independently of a server release.
Get Started with GrowthBookYour conference agenda has a new “Show room” button. Reviewers should see it on the first page load. Everyone else should get the existing agenda. If a Server Component renders the old agenda and a browser hook independently decides to show the new button, the first HTML and the browser can disagree.
In the Next.js App Router, the server can make this decision once and pass a boolean to the interactive component. We'll define the flag in the repo, select the preview audience with a local test cookie, and verify the actual HTML for both visitors. Clicking the button will still work after hydration. You can follow along without a GrowthBook account or client key. If you're assigning this work to an agent, the free feature flags for coding agents walkthrough gives the background.
Keep the flag definitions on the server
Use a TypeScript App Router project, or create a small one with create-next-app. These paths assume the project has an app directory at its root. If yours uses src/app, put both app and lib under src so the relative imports still match.
Keep the starter's root layout. Create lib/agenda-flags.ts with the following code. The SDK type registration update explains how LocalFeatures checks the flag and its rule against the registered types. This setup requires version 2.2.0 or later.
The module can reuse the client and rules across requests handled by the same process. It only holds the current visitor's audience inside the function call. Two requests can therefore use the same flag file and get different results. The Node.js SDK documents the scoped client used under the App Router here.
This particular rule has no percentage and needs no visitor ID. The two audiences are sufficient. If the team later asks for a rollout to 10% of attendees, add a stable attendee or registration ID and choose which of those units should stay together. Jeremy Dorn's Register pattern article explains how a change to an attribute type reaches the call sites that construct it.
Read the cookie for this request
Create app/agenda/page.tsx. The static heading can render for everyone. The request-specific content sits behind a Suspense boundary, so the fallback can show a neutral loading message until the server has the cookie.
The App Router's cookies function reads the incoming request asynchronously. Read it inside the visitor-specific component. Keeping that read out of shared cached code lets the surrounding page reuse common content without treating one visitor's decision as another's. This placement also accommodates App Router projects using Cache Components.
Give your agent the Next.js setup
Use the local flags guide with a concrete request to evaluate one flag on the server and return the same decision to the browser.
Open the Local Flags GuideThe cookie in this demo is a convenient way to preview a public UI treatment. Anyone with that cookie can see the room label. To target paying attendees or private sessions, obtain the audience from the verified session on the server and authorize the underlying data separately.
Pass one decision to the interactive component
Create app/agenda/Agenda.tsx. It's a Client Component because a visitor can open and close the room details. Its initial branch comes directly from the boolean supplied by the page.
The client boundary takes a serializable prop. The component receives true or false. The SDK instance, targeting rules, and cookie handling stay in the server module. You don't need a React provider for this component because its only browser-side choice is whether the visitor has clicked the button.
Follow one page load through server rendering and hydration. For a preview visitor, the server can send a section with a “Show room” button. React's first client render gets the same showRoom value and starts with open set to false. Hydration attaches the click handler. Opening the room detail then updates component state and doesn't require another flag evaluation.
Verify the HTML and the click separately
Build the production app and start it on port 3100.
In a second terminal, save this as verify-agenda.mjs in the project root and run node verify-agenda.mjs. The test makes two requests to the same route and looks for a marker on the rendered section. A marker in the HTML helps catch an implementation that only adds the intended layout after JavaScript runs.
Now open http://localhost:3100/agenda in a fresh browser profile. You should see the session title without a room button. In that local page's browser console, set the demo cookie and reload.
Click Show room and look for Room 204. Click Hide room and the room should disappear. This second check proves the component became interactive. If the server response test passes but the click fails, inspect the browser console for a hydration error before changing the flag rules.
Remove the fixture and reload once more. The button should disappear and the agenda title should remain.
The reload is deliberate. Editing the cookie in an already open document doesn't rerun its Server Component. In your app, use the normal session-change flow to request a fresh server render when a visitor signs in, signs out, or leaves a preview group.
Choose where the next flag should be evaluated
For a decision needed in the initial HTML, give the agent an observable requirement. Ask it to show the two HTTP responses, then click the interactive control in the preview. The first check catches an incorrect layout. The second catches correct HTML that never becomes interactive.
If a later feature depends on an action entirely within the browser, evaluate whether its flag belongs in the client tree. The one-shot local flags guide covers both placements. This agenda only needs one server decision. Updating its checked-in rule takes a deployment. Keep that tradeoff in view if the event organizer needs to pause a preview while attendees are already arriving. For that case, compare GrowthBook’s free options for changing flags between deploys.
Manage the agenda rollout in Cloud
Create a GrowthBook workspace when the organizer needs to adjust a preview audience while your Next.js app is serving attendees.
Get Started with GrowthBookReady to ship faster?
No credit card required. Start with feature flags, experimentation, and product analytics—free.




