Best A/B testing and experimentation platforms for mobile apps

A team ships a faster way to reorder groceries. On Friday, the dashboard says the new checkout wins. On Monday, support hears from people who can no longer repeat an order from a saved list. The discrepancy could be a real product tradeoff. It could also be a measurement problem. If the new screen crashes before sending its exposure event, the people most affected may be missing from the comparison.
The best mobile A/B testing platform for your team must do two jobs. It has to serve a consistent experience on a real device under imperfect conditions, and it has to produce a comparison you can defend when those conditions affect one variation more than the other. A web-based demo on fast Wi-Fi tests very little of either job.
Which mobile experimentation platform fits your stack?
| Platform | Strongest fit | What to ask the team to demonstrate |
|---|---|---|
| GrowthBook | Mobile teams that want the purchase ledger, subscription lifecycle, or other warehouse metrics to determine the outcome | Trace one native SDK assignment to a warehouse result, including somebody who leaves the app before completing the purchase |
| Firebase A/B Testing | Teams that already use Firebase Analytics and Remote Config and want a fast route to running native parameter experiments | Show when fetched values take effect and which users qualify for the experiment in your build |
| Statsig | Product organizations looking for an integrated SDK and experiment analysis workflow | Compare initialization, stable identity, exposure timing, and costs for the hosted or warehouse option under consideration |
| LaunchDarkly | Engineering teams that already manage releases through flags and want to attach tests to those delivery controls | Show how a flag evaluation, a metric event, and a subsequent flag change appear in the same mobile journey |
Keep the decision anchored to a change your installed app can actually make. For a checkout test, that might be switching the default delivery time between two options already implemented in the binary. If the alternative requires an entirely new address-validation library, the user needs the compatible build before any remote setting can enable the behavior. A platform can make either case look easy when its demo fleet consists entirely of the latest build.
Decide where the experiment starts
Write the first measurable event in ordinary language. “Fetched configuration” means a client received instructions. “Evaluated checkout choice” means the app reached the decision. “Rendered checkout” means the customer had an opportunity to see the result. These events can occur seconds or days apart. Pick an assignment point that gives the two groups comparable eligibility before the new experience can affect what happens, then collect later signals to explain the journey. If the customer crashes on render, that outcome belongs in the decision.
A remote toggle can also change a value at a terrible time. Imagine a delivery slot disappearing between the basket and payment steps because fresh configuration arrived while the customer was paying. Decide how long a choice should stay stable and where the next clean decision boundary is. Ask a mobile engineer to change the flag while the test device is sitting on the payment screen. Watch the transition with the PM who owns that screen. The right behavior here matters more than how many targeting rules a platform can display.
Set a performance budget before you add an SDK
Measure a fresh install, a warm restart with a populated cache, and a foreground resume on a lower-end supported device. Use an interaction the customer cares about, such as the time until checkout accepts input. Android distinguishes time to initial display from time to full display. An unchanged first-frame metric can hide a button that becomes usable later. Apple describes how to inspect launch time, hangs, and animation metrics with MetricKit. Choose comparable user-visible guardrails on each platform and check whether your telemetry can associate those outcomes with the experiment unit.
An aggregate from the app store can tell you a release needs investigation. To estimate a difference between variations you need a defensible link between assignment and the measured outcome. Record which crash sources supply that link, which report only build-level aggregates, and how long each takes to arrive. That prevents an operator from declaring the new checkout healthy while waiting for delayed crash reports.
Separate store distribution from the experiment population
Suppose you want to replace the address form in a shopping app. The old form and the candidate form can ship in the same build. The store determines who can install that build. Your experiment determines which form a qualifying shopper gets. Support needs both pieces of information. “I have version 8.4” tells them which code can run. It doesn't tell them which form the person saw when checkout opened.
This distinction matters even when the store selects people randomly. Apple's phased release for automatic updates progresses over seven days. During that period, anyone can manually download the update. On Android, a Google Play staged rollout makes an update available to a chosen percentage, and the team controls when to increase it. Some eligible devices take time to receive the update. The fraction of active shoppers running your code can differ substantially from the percentage displayed in the store console.
Forecast traffic at the point of assignment
Imagine 100,000 distinct users open the app in a week. Of those, 30,000 run a build containing both address forms. Only 12,000 of those users reach the checkout entry point where the app assigns them a variant. A 50/50 test should therefore get about 6,000 assigned users per arm. That works out to about 6% of the week's app users per arm. Older clients can keep receiving the established form, but their checkouts belong outside this comparison. Include them in your product-wide operational dashboard so that reliability problems on earlier versions stay visible.
Use distinct people or installations consistently in this calculation. If 12,000 is a count of checkout attempts and one person tries four times, it overstates traffic for an experiment randomized by person. Have the mobile engineer produce the distinct assignment count on one platform before finance or product uses the forecast for a launch date. Put iOS and Android on separate lines. A delayed Android release may change how precisely you can estimate an Android effect even while overall enrollment looks healthy.
Now suppose 1,200 of 6,000 assigned control users complete checkout within the specified window, compared with 1,260 of 6,000 assigned treatment users. That's 20% versus 21%, a difference of 1 percentage point, or a 5% relative increase. Those are illustrative point estimates. Precision still depends on the sample and design. The observed difference describes the eligible checkout population represented in the trial. Before forecasting a 5% increase in company-wide orders, account for shoppers on older builds, other checkout paths, repeat purchases, and uncertainty in the estimate.
A useful platform demo includes the assignment boundary. Ask the vendor to walk through a customer who opens checkout, gets assigned the new form, and experiences a crash before the form can log that it rendered. If your only record of treatment is a successful render, removing that customer can hide a real cost of treatment. Capture assignment at a common point before the forms diverge, and use a separate render event to diagnose delivery. Reconcile the ordering on a slow device or emulator. A seller who can show the two records can help you answer a more useful question than “Does the SDK log impressions?”
Rehearse a stop with the old build still installed
Put two devices on the trial bench. Give one a fresh configuration. Leave the other offline with yesterday's configuration, then disable the treatment remotely. Document the screen each device shows on its next checkout, whether a currently open form changes, and what happens after connectivity returns. A store rollout can stop distributing a bad build while devices that already installed it keep running it. A remote stop depends on when each client receives and uses the changed configuration. Neither control can repair a crash that occurs before the application reaches the relevant code.
Engineering teams have to choose when configuration freshness is worth spending startup time. The authors of MobileConfig for mobile apps at scale describe that tension in production systems. For a checkout test, preserving the form a customer is already filling out may matter more than applying a new value halfway through the session. Make the choice explicit. Have your test device open the address form, enter half an address, then reconnect while the other device is already using the fallback. Record the actual user experience and the version attached to the subsequent order.
Finally, ask how the team will end the experiment. Name the oldest supported build containing the winning behavior, the fallback for older builds, and the release that can remove the losing implementation. Before removing a remotely controlled branch, inspect usage of its oldest supported client and check whether checkout services still accept its requests. A platform that makes assignment easy still leaves a mobile release owner responsible for those customers. That owner should be able to open the pilot report and see who is still running which version.
Compare mobile measurement options
Review how GrowthBook and Statsig connect feature assignment to the data that determines an experiment outcome.
Compare Measurement OptionsGrowthBook for warehouse-native mobile experiments
Where it fits
GrowthBook is a strong choice when the valuable outcome happens somewhere other than the app screen. A mobile user can select a plan in the app, complete a purchase through a store, get a refund later, and return from another device. GrowthBook Experimentation can use the warehouse where those records are reconciled. Teams with working purchase and account models can use their existing definition of retained revenue instead of building one more in a mobile-only analytics interface.
Start a trial with an eligible app build and one consequence that matters beyond a tap. For a subscription renewal experiment, a click on the yearly offer is an explanatory signal. A completed, non-refunded annual purchase is a different outcome with a longer observation window. Ask the team to map which identifier the app knows at assignment, which identifier the purchase system emits, and how they can connect the two. If a meaningful share of purchasers cannot be joined, estimate where those customers disappear before making the chart available to decision-makers.
Strengths to test on a device
The GrowthBook Swift SDK and Kotlin SDK expose feature evaluation and experiment tracking in the native integration. Check the SDK overview for the integration your app actually ships. Put the evaluation in the part of the application that decides the experience. Wire the experiment callback to the event pipeline used by your connected warehouse. A callback alone cannot tell you whether the customer saw a completed screen. When that distinction matters, emit a separate rendered or interacted event after that stage and preserve the assignment when you analyze failures.
Follow a single test purchase through the data. Inspect the stable unit ID, experiment key, assigned variation, occurrence time, app build, and platform. Trace the purchase receipt to the same unit with the billing team's join logic. Count that assigned unit exactly once in the denominator even if the SDK evaluates the flag on several screens. Re-run the check for a customer who never completes a purchase. Their missing outcome should leave them eligible to contribute a zero where the analysis calls for it. Accidentally using an inner join to purchasers can make both variants look exceptionally profitable.
What the mobile engineers still need to own
The application's fallback value carries product consequences. If a cached flag is absent, the old checkout may be the only sensible default. If a recently installed binary has a bad configuration response, it still needs to handle the user's next tap. Decide how to record this default path, whether the user was actually assigned, and whether the analyzed population includes it. A forced QA value is excellent for testing the second screen. A test device manually forced into a variation provides little evidence about whether production assignments will be balanced.
For a second trial, use a real device that signs in partway through the session. A returning subscriber may start with an installation identifier and end the session with an account identifier. If the warehouse finds a single customer in both arms after login, the analysis owner needs a documented policy for that case. Compare the fraction affected by platform, then determine whether a different assignment unit or a different eligibility boundary would better fit the product.
Pricing and implementation considerations
Use the GrowthBook pricing comparison to price your deployment model, team seats, required controls, and warehouse choice. Calculate warehouse compute separately when bringing your own infrastructure. The recurring engineering cost includes keeping the assignment callback and billing joins correct across native releases. Bring your actual identity flow to a technical demo if purchases can move between an anonymous device, an authenticated account, and an app-store receipt. Proving a difficult join during evaluation can avoid months of disagreement about which outcome to trust.
Firebase A/B Testing for apps already using Remote Config and Analytics
Where it fits
A mobile team using Google Analytics for Firebase and Remote Config already has two pieces needed for an experiment. The app can implement both treatments, read a remote parameter to choose between them, and send an outcome the team already understands. A good first test might change the order of two steps in a profile editor. Both sequences work on a supported build. Both lead to the same saved profile record. The team can define success without introducing a metric that exists only in the new sequence.
Keep the change specific enough to prove that the app respects it. An older Android binary might understand the original order but ignore a new parameter entirely. Define eligibility by app and supported version, then run that older binary alongside the release candidate. Confirm that it continues to show a coherent experience. Include a phone that has turned off automatic updates in your trial. Verify the experiment excludes it even if its owner belongs to the target audience.
Choose when the app activates a value
A remote value can be available before the app should use it. Suppose the profile editor has already drawn the first question when a fetch finishes. Reordering the screen under someone's thumb can cause a wrong answer or an accidental dismissal. Give the screen one resolved order for the duration of the edit. Exercise the slow path on a physical device and record what happens if the app reaches its time limit while waiting for configuration.
Firebase's Remote Config loading strategies describe the tradeoff. For experiments, Firebase recommends fetching and activating behind a loading screen with a timeout because assigning the variant can take additional time. Decide whether the application can afford that wait at the relevant entry point. Set a maximum wait and run the first launch with an empty cache on a slow connection. Record how often the fallback path meets the deadline and whether the next visit uses a different assignment.
Separate configuration activation from experiment inclusion
Firebase uses the word “activation” in two places. Applying fetched configuration makes the value available to the app. An optional Analytics activation event determines which eligible users appear in the Remote Config experiment results. Users can receive experiment values even if they never trigger that event. Pick an inclusion event after configuration activation that both groups can reach before the changed experience influences behavior. The console requires a different event for the primary outcome.
For the editor, a common entry into the editing surface can be a reasonable candidate if it happens before either sequence appears. “Reached the biography question” could be a poor choice when the biography question moves from first to last in one sequence. That choice would remove early abandoners from one group disproportionately. Ask QA for one trace from someone who enters and leaves without saving. The trace should explain whether this person entered the experiment population and why they count as a non-converter. Run that exercise on both platforms because their navigation callbacks can fire at different moments.
Estimate requests as well as experiment traffic
Firebase pricing lists A/B Testing itself at no cost. Remote Config fetch requests have a separate daily allowance of 100,000 per project, with paid usage above that allowance on Blaze. Count actual fetches across the project's apps. A small experiment that reaches 5% of supported installations might run inside an app that fetches configuration across a much wider audience. Exporting and analyzing data in BigQuery can also add costs. Ask the person who owns startup and the person who owns the cloud bill to estimate the same rollout before selecting Firebase for its entry price.
Statsig for teams running native feature gates alongside experiments
Where it fits
Statsig fits mobile teams that want feature gates and randomized tests in the same SDK workflow. The iOS and Android clients can retrieve experiment parameters, log exposure checks, and record outcome events. A team that releases the same feature on both platforms can define one product question and implement each native surface in its own codebase. What needs to match is the meaning of entry into the experiment and the unit used to join outcomes.
Consider a reading app testing whether a prominent “Save offline” control helps subscribers finish articles on a commute. The first Android implementation might read the experiment in a feed adapter that preloads several article views. An iOS implementation might wait until an article appears. Both can render the correct button. Their exposure logs would describe different populations. A device that preloads ten articles and displays none could qualify on Android while its iOS counterpart never enters. That difference can survive a visual design review and materially dilute the Android estimate.
Put the check where the treatment can matter
Statsig's client SDK exposure semantics are important here. Reading an experiment ordinarily logs exposure at the time of the check, before the value returns. Place the read at the common point where a user can encounter the experience in either variant. If an app has to prefetch parameters, review the native SDK's methods for reading without exposure logging and recording exposure later. Delayed logging adds another code path. A control case that never calls it can make treatment look more widely used before a single reader changes behavior.
Use paired traces from a reader who swipes past the story and one who opens it. Include app build, experiment key, randomization identifier, and whether the article surface appeared. Use synthetic test accounts and compare the traces against the exposure stream. A reader who opens an article and never presses “Save offline” still belongs in the denominator if both groups had the opportunity. The app can record a successful download later, including when it resumes after an interruption.
Test assignment across device and account changes
Decide whether the question concerns a reader, an installation, or a subscription. Statsig's Android SDK generates a device-level stable ID and stores it locally. Clearing app storage or deleting the app can change that identity. Two subscribers who share a tablet may need separate assignments. One subscriber who reads on both a phone and a tablet may need one. If subscriptions determine eligibility, try a logout, an account switch, and a second device before committing to the identity model.
The native SDKs also offer device-persisted experiment assignments. With that option enabled, a previously stored value can survive a change to allocation or targeting while the experiment runs. Tell the trial team which outcome it should see after the allocation changes, then test it on an existing installation and a fresh one. Decide whether you need to preserve an established experience during a commute, or re-evaluate after a subscriber changes plans. Those are separate product decisions, and the tests should cover both.
Forecast the metered events
Statsig's hosted pricing lists two million monthly metered events on Developer. Pro lists $150 per month for five million, then $0.05 per extra thousand. Metered usage includes experiment exposures, logged or imported events, and certain metric operations. The vendor distinguishes this usage from unlimited ordinary gate and configuration checks. Use the definition for the deployment and contract you're evaluating.
To compare quotes, take a representative week and estimate completed article views, recorded outcomes, and other event traffic already using the same project. Account for exposure deduplication and the actual placement of SDK calls. An app with a large logged-out readership can generate a very different volume from one with the same number of paying subscribers but fewer reading sessions. If your experiment is the first to run on the feed, repeat the forecast with a second simultaneous test before turning one month's telemetry into an annual commitment.
In the trial readout, ask for the number of readers exposed, the number whose devices delivered a qualifying outcome, and the billed event count. Each has a different unit, and all three inform a buying decision.
LaunchDarkly for mobile teams that already release with flags
Where it fits
Consider LaunchDarkly if your mobile engineers already know which flag controls a screen, who can change it, and which fallback the app ships. Adding an experiment to that release process gives product and engineering a shared starting point. A travel app, for example, could test whether placing a saved boarding pass on the home screen helps passengers find it in time. The team already knows how to switch between home screens. The new work is to identify when someone actually encounters that choice and what successful retrieval looks like.
Bring the app's release engineer into the evaluation. Have them flag the boarding-pass shortcut in a test build and have the PM define the outcome separately. The PM may mean opening a usable pass. The engineer may already have an event for tapping the shortcut. If a tap opens a spinner and the pass never loads, the first event says the change worked while the passenger is still waiting. Pick the business event before wiring it to the platform.
What a native SDK evaluation tells you
LaunchDarkly supports native mobile clients that can use previously cached flag values while working in offline mode. Ask your team to demonstrate the experience after the app has loaded a flag online, then after installing the app fresh without a connection. Those are different paths through your code. A fallback that displays a perfectly usable legacy home screen can conceal the absence of a fresh experiment assignment.
For a custom conversion, LaunchDarkly describes both a flag evaluation and a metric event. Evaluate the flag where the app makes the decision that controls the screen. Record the metric where the app confirms the passenger opened the pass. A startup helper that reads every flag can generate an evaluation for passengers who never visit the home screen. During the trial, compare the number of distinct participating contexts against the app's own record of eligible screen entrances. Trace individual discrepancies before deciding which number belongs in a report.
What can change the quote
Ask for a quote that separates everyday mobile flag delivery from experimentation. LaunchDarkly's plan comparison is a starting point. Its billing definitions distinguish client-side monthly active contexts from experiment usage. Some contracts measure experiment keys per experiment, while others use experimentation MAU across the account. In the former model, the same context in two separate experiments can contribute to both. In the latter, that context counts once in a month under the documented uniqueness rules.
Take a representative month of distinct keys and estimate the overlap between your proposed tests. Also show what happens on sign-in, sign-out, and reinstall. A design that continually creates new keys changes the forecast and the meaning of a returning participant. If you need raw events for reconciliation, ask which export features your quoted plan includes. Get a second estimate for the next quarter, when the growth team and the mobile team expect to run tests at the same time.
Run a device trial before trusting the first result
Use a screen you can recognize when traffic is disconnected. In the boarding-pass example, the existing design opens the travel wallet from a menu. The treatment adds a shortcut to the home screen. Give each test account a pass that works offline. That isolates the behavior you're testing. A missing pass could otherwise make both versions look broken for reasons unrelated to the experiment.
Start with an empty cache, then try a stale one
Start a fresh install with airplane mode enabled and record the first screen shown, the value returned by the flag read, and the time until the passenger can open the wallet. Repeat with a connection and with a slow connection. On Android, distinguish time to initial display from time to full display. The system can draw the app's first frame while a disabled button is still waiting on configuration. On iOS, use launch measurements in performance tests alongside an app-level check that the wallet actually opens. Compare the same device and launch state across runs.
Next, put one test account into the shortcut experience while online, open the screen, and quit the app. Change the remote configuration while the device is disconnected. Relaunch without connectivity, then reconnect while the home screen is visible. Record what the passenger saw before and after the refresh. Decide whether you want the visible screen to update immediately or at the next navigation. A shortcut that moves while someone is reaching for it is a usability defect even if the eventual assignment is correct.
Repeat the stale-cache case with a different account on the same device. Note whether the previous account's variation flashes before the new identity resolves. Keep boarding-pass access protected independently of the feature flag. In this trial, the flag changes the route to the wallet. The app's ordinary authorization still determines which passenger may open a particular pass.
Follow one offline outcome through ingestion
For a known test account, record a screen entrance and a successful pass opening offline. Bring the app to the background, terminate it, then reopen it online. Track the screen decision and the outcome separately. If both arrive, compare the original occurrence times with the times the collection service saw them. The OpenTelemetry timestamp model gives the two clocks explicit names. A pass opened half an hour after exposure still belongs inside a one-hour conversion window even if its delivery happened the next day, provided your metric uses occurrence time and permits the delay.
Now reconnect just long enough for a request to leave the phone, then interrupt the response. A sender can retry an event the destination already accepted. Check the stable event identifier and the number of outcomes in the final report. Two deliveries for one opening should reconcile to one business action. Android's background work constraints and retry behavior also make this worth testing under battery and network restrictions. If you own the queue, record its retry policy and expiration. If the SDK owns it, ask which diagnostic evidence you'll have when the count falls short.
Trace the anonymous passenger through sign-in
A passenger might open the app as a guest, see the shortcut, then sign in to retrieve a saved trip. Repeat that journey and inspect the experiment participant key attached to the screen and the key attached to the outcome. An account identifier is a good unit for a signed-in cross-device experience. An installation identifier can cover a pre-login surface. Switching between the two during the same journey requires an explicit attribution rule, or you'll report views under one identity and successes under another.
Include a negative case in that ledger. Using a second test account, launch the app and navigate directly from a notification to the wallet. The passenger can retrieve a pass without ever seeing the home screen under test. Check whether that session enrolled in the experiment and whether its pass opening qualified as a conversion. This case reveals a surprising number of early evaluations and overly broad joins. It also gives the analyst a concrete example to rerun when someone later moves flag initialization into a shared startup component.
Make the trial deliverable a short ledger of what the passenger saw, which key received the assignment, which event counted, and when the result became available. Ask a mobile engineer and an analyst to reconcile it independently. If they agree on the totals but cannot explain the fresh offline install, keep that population visible in the analysis and resolve its eligibility rule before interpreting a lift.
Choose the platform that can explain a failed session
A mobile experimentation platform earns its place when your release engineer, analyst, and PM can explain the same customer's journey from build eligibility to a mature outcome. Give them a tricky session from the pilot. The phone opened offline, later signed in, and recorded a purchase the next day. They should be able to establish the treatment the device used, whether it entered the analysis, and when its revenue reached the report. If the evidence runs out halfway through, name the missing event or join before committing to the integration.
For a team whose business outcomes already live in a warehouse, GrowthBook is the strongest recommendation here. A mobile squad can choose the native implementation, track exposure through its existing event system, and use the same reconciled outcomes as the rest of the business. Start with one GrowthBook experiment whose result can be checked from a real device and an independent warehouse query.
Firebase is an attractive starting point for an app already organized around Remote Config and Google Analytics. Statsig deserves a trial when you value an integrated SDK and analysis workflow. LaunchDarkly belongs on the shortlist when your team already trusts it to govern releases and can demonstrate the experiment analysis it needs. Let the hardest session you reproduced, the operating cost you measured, and the decision your team has to make determine which one earns a wider rollout.
Test one native release
Start with a single supported app build and connect its first experiment to a business outcome your team can reconcile.
Start a Mobile 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.




