What is feature flag management and how do you choose a platform?

A support engineer has three customers on the phone. One sees a new billing screen, another sees the old screen, and the third sees a blank page. All three are on the same application release. The developer who added the switch is on vacation. The question facing the team is whether anybody else can explain the decision, change it for the right people, and check what happened afterward.
Feature flag management is the work of creating, delivering, changing, observing, and retiring the rules that choose which behavior an application serves. A flag lets you deploy code before making it available to everyone. Managing it means being able to answer which version of a rule ran, which inputs it used, who could change it, and what to do when the result is wrong. A dedicated platform earns its place when those questions have to be answered across people, services, and environments.
Identify the decision behind the switch
Imagine a reporting service with two ways to create a monthly statement. The old renderer works for every supported customer. The new one is faster on large accounts but has only been tested on a small set of templates. A release flag lets the team send a few internal accounts through the new renderer after both implementations are deployed. Changing a rule expands who gets the new output. Removing the old renderer later changes which fallback paths remain available.
Write the decision in a sentence a support engineer can use. “When a workspace requests a statement, use the new renderer only if its template version is supported and its workspace belongs to the rollout.” That sentence identifies the unit, prerequisite, controlled behavior, and fallback. The evaluation context is the data supplied to a flag decision. Sending a user identifier where the rule expects a workspace identifier can give two accountants at the same customer different statements.
Classify flags by their intended lifetime
Temporary release switches, experiment assignments, operational controls, and long-lived access decisions can all look like booleans in a dashboard. Their operating requirements differ. Pete Hodgson's feature flag taxonomy distinguishes flags along dimensions including how long they live and how dynamically their decisions change.
| Reason for the flag | Question to answer before enabling it | When its job is done |
|---|---|---|
| Release a new renderer | Can support identify which implementation produced a statement? | The team removes the obsolete path after verifying compatibility |
| Test a new statement layout | Which eligible unit is assigned, and which outcome will guide the decision? | The experiment ends and the team implements its decision |
| Shed an optional workload | Can the operator turn off expensive previews without disabling final statements? | The workload no longer needs this operational control |
| Enable a purchased capability | Which authoritative service validates the entitlement? | The underlying commercial rule or access system changes |
A single switch can accumulate contradictory jobs. A PM wants an experiment to hold assignment stable. Support wants an exception to get one customer past an incident. Sales wants its demo tenant to have the new layout forever. When all three use the same rule, the experiment readout can mix manual interventions with randomized exposure. Record the temporary exception separately, give it an expiry, and ask whether its subject belongs in the experiment population.
Know which changes a flag can reverse
Turning the new renderer off can route the next request to the old implementation. It cannot recall a statement already sent to a customer. If the new implementation also migrates a template or replaces stored data, a rollback needs a recovery plan for that state. Have the team walk through a partly completed operation before calling a switch a kill switch. Specify which requests can finish, which require retry, and which records an operator can use to determine the outcome.
The same distinction applies to access. Hiding the Export button can improve the experience for an account without the feature. A backend authorization check still has to decide whether a direct export request is allowed. Identify the owner of that check separately from the person who can customize the interface. That detail is easy to lose when the first implementation is a harmless internal preview and painful to rediscover once the feature contains customer data.
Decide where the flag gets evaluated
Imagine a feature flag that selects a new route for processing a customer's document. A settings page lets the release owner enable that route for a handful of accounts. At runtime, the worker handling each document needs an answer about its account. Those two operations happen at different rates. The release owner may edit the rule once a week, while thousands of jobs may check it in a minute. That difference is why the architecture for delivering rules matters as much as the interface for editing them.
Follow the rule from storage to the request
With local evaluation, an application loads the definitions it needs, then matches them against attributes available in its own process. Checking an already loaded rule can avoid a network round trip. The application still needs a way to obtain and refresh the definitions. A warm worker might keep using its last configuration during an outage while a newly started worker has never received any configuration. Treat these as separate cases in a proof of concept. GrowthBook's comparison of client-side and server-side evaluation shows how the location of the check affects which rules and attributes reach a browser.
With remote evaluation, an application sends the required context to an endpoint and receives the result. That can keep targeting logic on infrastructure your team controls. It introduces a network dependency at the point where fresh results are obtained. Some implementations reuse evaluated values. Ask what the cache key contains and what forces a new evaluation when a user changes accounts. In GrowthBook's remote evaluation for Python, PHP, and Java, for example, the application uses a self-hosted proxy or edge endpoint. That endpoint is another service for the team to deploy and monitor.
Draw the access boundary
A browser deciding to display a download button and a server deciding to deliver the file have different responsibilities. A client may receive a flag indicating that a preview is available. The server handling the download still needs to check the caller's permission for that file. During evaluation, give a test account permission to view the feature but no access to another team's document. Verify that the application continues to enforce that boundary with the flag on, off, and missing.
For tenant-specific features, specify where the account identifier originates. A trusted server can derive it from the user's authenticated membership and the current request. A shared edge cache serving individualized results needs a key that accounts for the relevant scope. Demonstrate two authorized accounts in one browser, with different flag values, and switch between them. A surprising result there warrants investigation before the platform controls a broader rollout.
See how flag rules scale
Explore the engineering choices behind targeting and delivering flags as more services and teams adopt them.
Read the Engineering GuideTest delivery failures before depending on a kill switch
Distinguish the default from the last known value
A flag's configured default, an application's fallback, and yesterday's cached treatment can all be different. Suppose the document worker normally uses the established route, but a rollout moved a few accounts to a new one. If it can't fetch new rules, continuing with a known configuration preserves continuity. If the new route is dropping documents, that same behavior can prolong the incident. Decide how long a stale decision remains acceptable for this specific operation. The OpenFeature evaluation API provides a useful comparison point for typed fallback values and detailed evaluation results when a provider encounters an error.
Run the failure test twice. First, disable configuration delivery after the test worker has fetched the new rule. Then start another test worker without a local cache while delivery remains unavailable. Submit the same kind of job to each. Record the route taken, the age or revision of the available configuration where known, and the reason the application gives for its decision. A report that only shows a boolean cannot explain whether a deliberate rollout or a fallback sent traffic down that path.
Measure when clients actually change behavior
When the owner switches the new route off, sample the next jobs from a warm process, a freshly started process, and an edge region outside your usual office location. Record the time of the edit, the first observed change, and how long the oldest observed process continued using the prior version. Check both the flag payload and the final rendered response if a CDN caches either. HTTP cache directives can permit stale responses during revalidation or certain upstream failures. Purging one layer may leave another serving an earlier result.
Repeat the exercise with a mobile device that was suspended or offline at the time of the change. On iOS, the operating system schedules background refresh opportunities. The next foreground session can be the first realistic chance for a disconnected device to learn about a change. If a flag controls an operation that must stop centrally, identify the server-side check that can refuse new work while clients catch up.
Finish with a job already in progress. Switching the flag can affect the next evaluation. The job may have selected its route ten minutes earlier and persisted it in a queue. Determine whether that job should finish normally, retry through the established route, or wait for human review. The release owner needs that answer to decide whether a flag change has contained the incident or whether additional recovery work remains.
Put a name and an end condition on every release flag
Suppose your payments team wants to replace the way its app selects a shipping address. The new picker reads from a different address service. Both versions can run in production. The flag record should name the engineer who can explain either path, the team responsible for responding after hours, and the condition that makes the release flag unnecessary. “Remove after launch” gives the next engineer very little. “Remove when supported mobile clients use the new picker, the address service meets its error target, and the old path has no remaining consumers” gives them evidence to collect.
The intended lifetime shapes all three decisions. A release flag for an address-picker migration should have a cleanup issue and a date to revisit it. A long-lived operational control that reduces load during an outage needs an owner, a rehearsal schedule, and a documented restoration procedure. Giving both the same expiration date creates two bad incentives. Engineers may delete a useful incident control or keep extending a release flag because nobody knows what depends on it. GitLab's feature flag development process offers a concrete example of tracking rollout and removal as software delivery work.
Test production permissions with a real change
Give a developer the ordinary access their team would receive. Ask them to create a change in a test environment, draft the equivalent production rule, and request a review. Have a second person check the audience, proposed value, and rollback value. Then have the author widen the audience after approval. Can the reviewer see the difference? Does the original approval still authorize publication? A platform that preserves an approved revision and its history makes these questions answerable after the fact. GrowthBook's guidance on flag change review explains how drafts and approval flows apply when a coding agent helps prepare the change.
Use two additional identities in the trial. A support engineer should be able to find the production history they need to explain a customer's experience. A service account that creates preview environments should have only the project and environment access its job requires. Ask each to perform one permitted action and one action outside its assigned scope. Save the actual result. A diagram of roles won't tell you whether a broadly scoped token can bypass the same review a developer faces in the interface.
Rehearse the address-picker incident
At 10:12, support reports that customers are selecting an address and then returning to the same screen. The dashboard shows elevated address lookups, but the on-call engineer doesn't yet know whether the new picker caused the loop. Ask someone to locate the last production revision, identify its audience, and compare affected sessions to the rollout time. A second responder should inspect a known customer journey so a traffic spike alone doesn't decide the diagnosis. Use test accounts and a nonproduction environment for this rehearsal.
Time the complete mitigation. The responder narrows or disables the rule with the designated incident permissions. A verifier checks that a fresh session now reaches the old picker, then confirms that the stuck-session rate is falling for the affected population. Existing sessions might be mid-checkout, and queued data can make a graph lag behind the customer experience. Record the change time, first successful customer journey, and metric recovery as three distinct observations. Google's incident response practice separates operational work, coordination, and communications so one responder can keep investigating while another records what changed.
After the drill, inspect the audit trail as someone who wasn't present. It should identify the actor, revision, environment, and change. Link it to the incident record for the rationale, the observed result, and the person responsible for restoring normal targeting. If emergency access requires an elevated role, verify how a responder obtains it and who removes it afterwards. The drill is where you discover that the only authorized approver is asleep in another time zone.
Remove the flag in an order that protects older clients
Once the new picker works, enabled traffic is only one part of the retirement decision. Search the mobile apps, server, background jobs, tests, and dependent targeting rules for the flag key. Ask whether a client constructs keys dynamically. Look for the version that last shipped the old branch and the fallback that version uses when a key disappears. A search of today's main branch can find zero references while yesterday's phones are still evaluating the flag. Apple's phased release process is one example of why releasing an update and reaching devices happen on different schedules.
Write the change in two parts. First, remove the obsolete branch from the binaries and services you control, keeping the remote value old consumers still need. Verify the permanent path in an ordinary checkout and verify the behavior of an older supported client. Next, retire the remote rule after you have evidence that remaining callers can take its eventual fallback. For a shared flag, ask every consumer's owner to sign off. A team that sees no mobile calls may simply have excluded older SDK versions from its reporting.
Have an engineer review the code change and list the tests they'll keep for the permanent behavior. Keep the retirement issue linked to the pull request and the final flag revision so a future incident reviewer can trace the transition. GrowthBook's stale-flag cleanup walkthrough illustrates how to inspect usage and references before preparing a cleanup. The person accountable for the feature should decide when the evidence covers the supported clients.
Price the release you intend to run
Bring a month's architecture and staffing numbers to the pricing discussion. A team might have 12 people who need to change flags, 60,000 customers who sign into the app, and another 150,000 anonymous browser identifiers that see a landing-page flag. If a contract counts each distinct client identifier in this example and none overlap, that's 210,000 identifiers. The finance team's tally of paying customers gives a different forecast. Determine what happens when an anonymous browser signs in, when a customer changes devices, and when the same installation contacts two environments.
Make a second estimate that changes one thing. If a successful campaign doubles the number of anonymous identifiers, the example rises to 360,000 while the team still has 12 people changing flags. If you expand flag ownership from 12 to 20 teammates with traffic steady, a seat-based quote could rise while a client-usage quote stays flat. Ask which teammates need paid access to approve a change, view an audit record, or pause a release. Compare the seats and usage that let the on-call team do its job.
You can see these differences in public packaging. LaunchDarkly lists client-side monthly active users and server-side service connections as distinct units. A process that evaluates the same flag many times can still be one connection. GrowthBook publishes seat-based Cloud plans and explains its fair-use terms for hosted services. Model the configuration fetches and infrastructure your implementation will generate. Take the numbers from a representative client session and server deployment, especially if a proxy, a short-lived worker, or a second production region changes how clients connect.
Put the operational work next to the subscription
For each finalist, ask an engineer to estimate the time to ship the first flag on one service and retire it. Then ask the person who owns releases about recurring work. Who maintains targeting attributes? Who approves an emergency change when the usual reviewer is away? What will it cost to keep another year's audit history or restore the platform configuration? A quote can include the flag itself while leaving the organization to build the approval or recovery workflow it requires.
Self-hosting changes the cost calculation again. Include infrastructure, upgrades, restoring from backup, and time on call. Keep those estimates separate from work every deployment model needs, such as removing the conditional after the release. When a team already operates the relevant database and deployment system, its incremental hosting cost may be modest. If ownership would fall to a single engineer taking their first production pager, write that constraint down before evaluating a license discount.
Rehearse the exit while the trial is small
Use a reversible change, such as a new sort order for an internal report. Record the flag key, type, fallback value, environment, and two targeting rules in plain language. Create a short set of test identities with expected results, including an identity missing the attribute that the rule checks. Have a second engineer reproduce those results in a disposable environment from the written description. Check the outcomes and the reason for each decision if the SDK exposes one. A green result for a user who fell through to a default may conceal a broken rule.
If your team uses OpenFeature, its evaluation API gives application code a common interface to request a typed value and supply a default. The provider connects that interface to a particular implementation. Swapping providers still leaves targeting precedence, percentage assignments, prerequisites, and historical records to check. Re-create a percentage rule and compare assignments for the same fixed identities. Two platforms can both deliver a 10% rollout and choose different people.
Finish the trial by removing the flag from the sample service. Verify that the chosen behavior survives a restart, that the old configuration can be archived, and that a teammate can still retrieve the record explaining the change. Those steps give you an estimate for the thousandth flag as well as the first.
Make the buying decision on a release your team recognizes
Give the finalists the same release story and ask a developer, product owner, and on-call engineer to complete it together. Someone should deploy the dormant path, someone should target a pilot account, and someone else should diagnose a deliberately unexpected result using only the access an ordinary operator would have. End by documenting the cleanup owner and what happens to any offline client still running the old binary.
When evaluating GrowthBook feature flags, take the same questions to the SDK and environment choices you would use in production. A team that only needs a small set of stable switches can begin with a simple implementation and use the trial to locate the point where shared management starts saving work. A team running several production services may care more about rule history, independent permissions, and how quickly another operator can recover.
Keep the evidence from that release next to the purchase decision. If the engineer can explain one customer's value, the operator can narrow a problem without making it worse, and the owner can take an obsolete flag out of service, you know what the platform has earned. If any step requires the salesperson's account or the original developer's recollection, the unresolved step belongs in the implementation estimate.
Try a controlled release
Use a pilot workspace to test who receives a feature, how the fallback behaves, and what your release operator can observe.
Try GrowthBook FlagsRelated 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.




