DORA metrics: Measuring software delivery performance

Doubling deployment frequency is not much of a win if the extra deployments repair yesterday's failures.
A team moves from weekly releases to several deployments a day. The dashboard looks healthier. Then the on-call rotation explains that many of those deployments are unplanned fixes, and routine changes still wait days for review. The higher count describes activity, but it does not explain the delivery system.
DORA metrics help teams examine how changes move into production and what happens when they get there. They are useful when the application boundary, event definitions, and interpretation remain consistent. They become misleading when every pipeline job becomes a deployment or a shared process turns into an individual leaderboard.
This guide covers the current five-metric framework, a practical event contract, worked calculations, and a way to turn the result into one concrete improvement. It also explains where feature flags help and why deployment performance still needs separate evidence of product value.
Understand the current five-metric framework
Read throughput and instability together
DORA's current software delivery guide identifies five metrics in two groups. Throughput covers change lead time, deployment frequency, and failed deployment recovery time. Instability covers change fail rate and deployment rework rate.
| Metric | What it describes | Direction generally associated with improvement |
|---|---|---|
| Change lead time | Time from code commit to production deployment | Shorter |
| Deployment frequency | Deployments in a period, or time between them | More frequent delivery when useful |
| Failed deployment recovery time | Time to recover from a deployment failure requiring intervention | Shorter |
| Change fail rate | Share of deployments requiring immediate intervention | Lower |
| Deployment rework rate | Share of deployments that are unplanned incident-driven work | Lower |
The measures describe related parts of a system. A useful review asks whether work flows more easily while avoidable intervention declines. Optimizing one number without inspecting the others can conceal a new problem.
Update historical terminology without rewriting history
Many articles still describe the original four keys. DORA's history of the metrics explains the evolution: recovery was narrowed to failed deployments, and deployment rework rate was added to the delivery model. Operational reliability remains important, but it is not interchangeable with that newer rework measure.
If your dashboard uses “MTTR,” inspect what the field actually contains. It might mean time from an alert to incident closure, the average duration of every outage, or recovery after a deployment failure. Renaming the label does not make those definitions equivalent.
Preserve the old series when changing your calculation. Annotate the definition change and, where feasible, compute the old and new measures side by side for a transition period. Otherwise, a better-looking chart may simply reflect that unrelated incidents were removed from its population.
Choose an application boundary before a target
Start with one application or service and the team responsible for building and operating it. An organization-wide total can combine a high-frequency web service, a mobile application constrained by distribution, and an internal batch system with very different workflows.
Document the boundary: production environment, deployable artifacts, repositories, service ownership, and incident scope. If several repositories form one deployed application, commit lineage needs to reflect that relationship. If one repository contains many services, a repository-wide deployment count may obscure the actual unit of delivery.
This is a system diagnostic. Commit counts and deployment counts are poor individual performance scores. The SPACE framework's productivity research explains why developer productivity cannot be reduced to one activity measure. Use delivery evidence alongside collaboration, experience, and outcomes.
Build a consistent deployment and incident record
Separate a deployment from its pipeline events
A build, a staging deployment, and a production deployment are different events. A production rollout can also generate dozens of events as regions or replicas update. Decide which records represent one logical deployment and deduplicate them consistently.
For a regional rollout of the same artifact, your team might define one logical production deployment with regional child events. Another architecture may require separate independently operated services. The policy should reflect how the application is delivered, not whichever convention gives the largest count.
Record unsuccessful attempts separately from successful production delivery. A failed CI test that prevents production change is useful pipeline evidence, but it is not automatically a production change failure. Keep the raw events so you can revise derived classifications without losing the underlying history.
Join changes, deployments, and incidents explicitly
| Evidence | Useful fields | Main check |
|---|---|---|
| Change lineage | Commit identifier, repository, commit time, artifact | Is this change actually included in this artifact? |
| Production delivery | Logical deployment ID, service, artifact, time, outcome | Is this a deduplicated event for the defined boundary? |
| Failure and recovery | Incident ID, causal deployment link, impairment and restoration times | Did a deployment cause the qualifying problem? |
| Remedial deployment | Deployment ID, incident link, planned/unplanned classification | Was this delivery incident-driven rework? |
Do not infer the causal deployment solely by choosing the nearest deployment before every alert. Several changes may be involved, and some incidents are unrelated to a deployment. Use incident review and available traces to classify the relationship, retaining uncertainty when the link is unresolved.
For recovery, distinguish the start of user impact, detection, mitigation, restoration, and administrative closure. Your team needs a documented timestamp policy that matches the intended measure. Closing an incident ticket the next morning should not make an otherwise restored service appear impaired all night.
Keep deployment and exposure events separate
A feature may be deployed disabled on Monday and exposed on Thursday. Feature flags make that separation deliberate. Record the artifact deployment and the exposure change as distinct events linked to the same feature or change when possible.
That distinction also matters during incidents. If a Thursday flag change activates already-deployed faulty code, preserve the deployment lineage, the activation time, and the recovery action. Review how this case belongs in your delivery metric policy rather than silently counting a flag toggle as another code deployment.
The record remains useful beyond DORA. It helps answer which users experienced a behavior, which artifact contained it, and whether disabling exposure restored the service. A count alone cannot answer those questions.
Validate a handful of real changes before building the dashboard
Trace one ordinary change, one rollback, one hotfix, and one unrelated incident manually. Confirm that the records tell the story the team remembers. Check identifier types, time zones, duplicated webhook deliveries, delayed events, and missing incident links.
Do not replace unknown classifications with false. A record with no failure annotation may mean success, incomplete ingestion, or an incident that has not been reviewed. Report classification coverage so a sudden improvement does not merely reflect missing data.
Give the event contract an owner and a version. When a deployment tool changes, inspect a sample of new events before trusting continuity. Measurement maintenance is part of operating the system, especially when your dashboard combines several independently evolving sources.
Link deployment to controlled release
Explore feature flag practices that keep exposure, ownership, monitoring, and cleanup visible after code reaches production.
Read the Flag PracticesCalculate the metrics without creating false precision
Use a small worked period to test the denominators
Suppose a hypothetical service has 20 qualifying production deployments over 10 working days. Of those deployments, 2 cause production problems requiring immediate intervention. Separately, 3 of the 20 are unplanned remedial deployments linked to production incidents.
Under that stated contract, deployment frequency is 2 per working day, change fail rate is 2 divided by 20, or 10%, and deployment rework rate is 3 divided by 20, or 15%. Label the working-day denominator; a calendar-day rate would differ.
The failure-causing deployments and the remediation deployments are not the same classification. A single bad deployment can require multiple fixes. A remedial deployment can itself cause a failure. Preserve those relationships rather than assuming the two percentages must match.
For example, deployment D07 causes incident I01 and requires hotfixes D08 and D09. Deployment D14 causes I02 and requires D15. D07 and D14 contribute to the failure numerator; D08, D09, and D15 contribute to the rework numerator. The denominator remains the documented set of 20 production deployments.
Summarize durations with their sample size
If the 2 qualifying failures recover in 18 and 42 minutes, their median is 30 minutes. That is a description of 2 observations, not a stable estimate of the team's future recovery capability. Show the individual events and the small sample size alongside the summary.
For 5 completed changes with lead times of 10, 14, 20, 28, and 96 hours, the median is 20 hours. The 96-hour change still matters. Inspect whether it waited for review, a deployment window, an integration dependency, or a deliberate risk decision.
Use consistent aggregation and show the distribution where it helps. A median can hide a painful tail; a mean can be dominated by one extreme event. Neither is sufficient without context. If no qualifying failure occurs, recovery time is unavailable for that period, not automatically zero.
Keep the population and observation window visible
Lead time typically summarizes changes that reached production during the selected period. Work still waiting is absent from that completed-change population. Pair the result with aging work so a fast median does not conceal a growing queue.
Choose how to handle commits that appear in multiple deployments, cherry-picks, squashed changes, and rollbacks. For this guide's lead-time calculation, map each included commit to its first successful production deployment under the documented application boundary. The purpose is to measure flow from change to production, not to multiply the same change across every later artifact that contains it. Verify a few examples against the real history.
Incident classifications can arrive late. A deployment may look healthy today and later be linked to a discovered regression. State whether recent figures are provisional and how far back the dashboard restates. Preserve old results or definition versions when the team needs to audit a decision.
Use benchmarks as context
DORA's Quick Check documentation describes current research-based comparison. Benchmark definitions and populations can evolve. Check the source and year before copying a threshold from an old slide into a permanent target.
The most actionable comparison is often the same application over time under a consistent definition. Comparing teams without their architecture, risk, and operating context can reward favorable circumstances rather than better practices. If a comparison is needed, discuss those differences explicitly and use it to form questions, not assign blame.
Improve the delivery system behind the numbers
Find where work waits
When lead time is long, separate active work from waiting. A change may spend 30 minutes in tests and 2 days waiting for review. Buying a faster runner will not remove that queue.
Value stream mapping gives a team a way to visualize the path and identify constraints. Map a recent real change with the people who handled it. Include handoffs, approvals, rework, and time waiting for an available environment.
Choose one constraint to address. If review queues dominate, try smaller changes, clearer ownership, or a review rotation. If environment setup dominates, improve repeatability and access. If tests are flaky, classify failures and repair the feedback signal before encouraging more frequent retries.
Reduce batch size with adequate validation
Smaller changes can be easier to understand and reverse, but splitting work mechanically into empty deployments does not improve the system. Aim for independently understandable changes that can be validated and delivered with less coordination.
Continuous delivery practices connect deployability with testing, integration, and operating discipline. Automation is useful when it produces trustworthy feedback. A fast pipeline that skips important checks can shift work from delivery into incident response.
Look for evidence that the change helped. Lead time should improve for meaningful work, avoidable intervention should not rise, and developers should report less friction. Read these signals together instead of declaring success because one deployment counter increased.
Make recovery a tested capability
If recovery is slow, inspect detection, diagnosis, access, rollback mechanics, data compatibility, and decision ownership. Some failures wait for an unavailable specialist rather than a technical fix.
Practice a bounded recovery scenario in a safe environment. Confirm that the intended operator can identify the deployed artifact, disable exposure or restore a known version, and verify the result. Record what cannot be reversed, including data migrations or external actions.
A shorter recovery summary is valuable when it reflects real restoration. Reclassifying incidents to remove difficult cases or closing tickets earlier improves the chart without improving the user experience. Keep incident learning open and separate operational accountability from metric gaming.
Pair delivery performance with reliability and product outcomes
DORA measures how software moves through delivery. It does not prove that the delivered changes solve a user problem. A team can deploy frequently and deliver a feature people do not need.
Keep operational reliability objectives and customer outcomes alongside the delivery view. Depending on the product, that may include successful task completion, latency, retention, conversion, support burden, or cost. Define the outcomes before evaluating the release.
When you need causal evidence of product impact, a well-designed experiment answers a different question from a deployment trend. Delivery metrics reveal process behavior; experimental outcomes estimate the effect of assigning a product change within their design. Neither substitutes for the other.
Fit feature flags into the evidence chain
Control exposure while preserving the deployment record
A team can deploy a small change, enable it for an internal cohort, and expand after checking behavior. Targeting conditions support that control using application-supplied attributes. Keep the eligibility and identity contract explicit so the recorded cohort matches real exposure.
For compatible changes, a disabled flag can provide a faster path away from problematic behavior than a full redeployment. That is an engineering option, not a guarantee. Verify configuration propagation, fallback behavior, and any work already in progress before treating disablement as recovery.
Flags also create work: ownership, review, stale branches, dependencies, and cleanup. A delivery improvement that leaves hundreds of unmanaged switches can create future risk. Track retirement as part of finishing the change.
Monitor user harm with the right metrics
Safe Rollouts combine gradual exposure with configured guardrail monitoring. The usefulness of that signal depends on correct assignments, events, metric definitions, and adequate data. Keep immediate operational alerts available for failures that cannot wait for experiment analysis.
Shared metric definitions can help a team use consistent outcomes across release and experiment decisions. They do not automatically reconstruct Git history, production deployments, or incident causality. Building the DORA view still requires the event contract described earlier.
Link the records where useful: change, artifact, deployment, exposure rule, incident, recovery action, and product result. The goal is to explain the delivery and user experience together without confusing their units of measurement.
Run an improvement review the team can use
Establish a baseline and a hypothesis
Begin with one application and a baseline whose data you have inspected. Review the five metrics with the people who prioritize, build, deliver, and operate the service. Ask where the delivery story conflicts with their experience.
Select a specific improvement and an owner. For example, reduce the queue before production by making routine deployment self-service for authorized operators. Define what should change, what must not regress, and how long you need to observe representative work.
Suppose the team finds that routine changes wait for a weekly coordination meeting even after tests pass. Its baseline lead-time distribution has a long waiting tail, while the deployment step itself takes little time. The hypothesis is that an approved self-service path for routine changes will reduce that waiting without increasing intervention or on-call work.
Write the intervention precisely. Define which changes qualify, which checks remain required, who may initiate delivery, how deployment evidence is recorded, and what happens if a check fails. The change is a different operating path, not permission to bypass validation. Keep exceptions visible so urgent or high-risk changes do not silently enter a process designed for routine work.
Choose observations that can test the mechanism. Alongside lead time, inspect time waiting after successful validation, the mix of changes delivered, failure and rework classifications, and developer reports of coordination effort. If the average batch suddenly becomes much smaller, record that context. It may be part of the improvement, but it also changes the interpretation of simple counts.
Review the evidence and keep the next action small
At the next review, inspect the metric trend, a few individual changes, incident evidence, and the team's experience. If the result is unclear, refine the measurement or the intervention. Avoid adding a new target simply because the previous one was easy to report.
Imagine deployment frequency rises and median lead time falls, but several changes still wait for days because another team owns a required dependency. The intervention helped one queue; it did not solve every constraint. Keep the working self-service path and investigate the dependency handoff as the next focused improvement. Do not hide the older waiting changes by reporting only the median.
Alternatively, suppose frequency rises mostly because operators retry failed deliveries. That result does not support the original hypothesis. Review deduplication and the failure path, then fix the operational problem before encouraging further use. A count that moves in the desired direction can still contradict the mechanism you intended to improve.
Keep the review record concise: baseline period and contract version, intervention, expected mechanism, observed evidence, unresolved uncertainty, and next decision. Include the people who experience the work. A manager may see a faster dashboard while an on-call engineer sees extra manual cleanup; both observations belong in the assessment.
Check whether the observation period contains comparable work. A quiet maintenance week and a major migration can produce different delivery patterns. Preserve that context and avoid attributing every short-term movement to the process change before enough representative changes have passed through it.
Revisit the collection burden as well. If a field requires extensive manual classification but never changes a decision, simplify it or explain why it remains necessary. Conversely, if every review depends on reconstructing deployment lineage from chat messages, automate that evidence capture. The measurement system should make useful conversations easier, not create another process the team must work around.
The useful output is a repeatable loop: trustworthy events, a shared explanation, one change to the system, and evidence of its effect. DORA metrics help keep that loop grounded when they remain a tool for learning about delivery rather than a substitute for understanding it.
Connect delivery with user outcomes
Use GrowthBook to control release exposure and measure product changes with metrics grounded in your existing data.
Get StartedFAQs
The current software delivery performance model uses five: change lead time, deployment frequency, failed deployment recovery time, change fail rate, and deployment rework rate. Older four-key material reflects earlier versions of the framework.
No. It focuses on recovery from a production deployment failure requiring intervention. Broader operational incidents remain important but should not be silently mixed into that delivery measure.
Record deployment and exposure events separately and document your measurement policy. Feature flags can change user exposure after code is deployed, so treating every flag edit as a new deployment would obscure that distinction.
They describe the delivery system for an application or service and are poor individual performance measures. Review bottlenecks and reliability with the cross-functional team rather than attributing shared outcomes to commit authors.
The controls described here support release exposure, guardrail monitoring, and product measurement. A complete DORA calculation still needs appropriately joined source-control, deployment, and incident evidence; experiment metrics do not automatically provide that lineage.
Related 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.




