October DealsAmazon USOctober deal check: compare before you payAmazon US: current deals, useful picks and tech finds.Check DealsWindows FixRecommendedWindows errors stealing your time? Find the fix fastScan stability, cleanup and performance issues.Fix NowOctober DealsAmazon USDeal season is back - check today's better picksAmazon US: current deals, useful picks and tech finds.See Picks×
Skip to content
World desk5 min

How to Add React Feature Flags Without Putting Rollbacks in the Browser

Use a client SDK for browser-facing React flags, keep authorization on the backend, and make nightly rollback jobs observable, protected, and safe to retry.
Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

Use a client-side flag SDK to control React UI, but keep authorization, sensitive rules, and deployment rollback decisions on trusted backend systems. A nightly job can check health and start a rollback, but scheduled CI is not an exact-minute timer—and changing a flag is not the same as restoring deployed code.

How should React feature flags be divided between frontend and backend?

Let the React app evaluate flags intended to control browser-visible experiences, such as whether to show a new interface. Keep security-sensitive decisions—who may access data or perform an action—on the backend, where a user cannot bypass the check by changing browser code or requests.

As an Amazon Associate I earn from qualifying purchases.

For a concrete example, LaunchDarkly’s React SDK documentation says to make a flag available to the client SDK and warns: “Never embed a server-side SDK key into a client-side application.” Use the provider’s client-side identifier in the browser, not a server-side credential. Treat any flag value delivered to a browser as information the user can inspect; a hidden button is not access control.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

Initialize the chosen SDK at the application boundary with the appropriate user or other evaluation context. With LaunchDarkly, the documented React options include asyncWithLDProvider, which waits for initialization before rendering, and withLDProvider, which renders first and processes initialization and updates afterward. The SDK also provides React context and hooks for reading flags. Check the current provider documentation and package version before implementing, since APIs can change.

Choose how the first render behaves

Approach What the user sees Trade-off
Wait for initialization The app delays its first render until the SDK initializes. Reduces the chance of briefly showing a fallback state, at the cost of delaying the UI.
Render with fallback values The app renders immediately using configured fallback values, then may update when flag values arrive. Improves initial responsiveness, but a fallback screen can visibly change after initialization.

For LaunchDarkly, the React SDK documentation states that an unavailable client flag returns its fallback value. Pick fallbacks deliberately: they should leave the interface in a safe, understandable state if initialization fails, not grant access to protected data or actions.

Should feature flags be checked in the frontend or backend?

Use the frontend for presentation choices and the backend for decisions that protect data or enforce business rules. If an action must be restricted, the server must enforce that rule even when the React UI also hides or disables the relevant control. A client flag can improve the experience; it cannot replace server authorization.

Also distinguish flags that are suitable for client evaluation from server-side flags. A flag should be exposed to a client SDK only when its value and purpose are appropriate for the browser. Keep credentials environment-scoped and follow the provider’s least-privilege guidance. LaunchDarkly’s API overview distinguishes server SDK keys, mobile keys, and client-side IDs, and describes environment-specific identifiers and read-only operations for the keys covered there. Do not infer that a read-only credential can change flags or initiate a rollback.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

How often should a backend poll a feature-flag API?

First decide which component needs updates. A backend service that evaluates server-side flags has different credentials and delivery choices from a browser client consuming client-authorized flags. Avoid having every React component or browser session poll an administrative API. Prefer the provider’s supported client SDK or service-side mechanism for the relevant environment.

Polling and streaming are different ways to receive changes. Streaming maintains a connection for updates; polling checks periodically, so changes may wait until the next request. Streaming has connection and reconnect behavior to manage, while polling creates recurring requests and must respect the provider’s limits. Neither approach has a universal cadence or failure policy.

For LaunchDarkly implementations polling its evaluation API, its SDK contributor guidance recommends one call every thirty seconds and a throttle of at most one request per second. These are LaunchDarkly-specific recommendations, not universal polling rules. Before choosing a cadence for another provider—or a different endpoint—check its supported API, authentication, rate limits, caching guidance, and retry behavior.

Plan for stale data and outages

Define what the service should do when an update request fails. A robust policy can retain a safe last-known value or use a safe fallback, bound retries with backoff, and surface how stale the value is. Avoid retry loops that turn an outage into a burst of requests. These are engineering safeguards, not guarantees made by the provider documentation.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

How can a nightly pipeline coordinate a rollback?

Separate detecting a problem from choosing an action. A scheduled job should gather a defined health signal, compare it with a team-chosen threshold over a stated time window, and then alert, request approval, change an appropriate flag, or revert a deployment artifact. The health metric, threshold, observation window, and action policy depend on the application; GitHub Actions does not prescribe them.

For example, GitHub Actions supports scheduled workflows using POSIX cron. GitHub documents that schedules run against the latest commit on the default branch, use UTC by default, and have a minimum interval of five minutes. Under high load—especially near the start of an hour—runs can be delayed and some queued runs can be dropped. In public repositories, scheduled workflows are automatically disabled after sixty days without repository activity. Therefore, treat a nightly schedule as a trigger to check, not a promise that a job will start at a precise minute.

on:
  schedule:
    - cron: '17 2 * * *'

This example requests a run daily at 02:17 UTC. It does not guarantee the run will begin then. Keep the job observable, safe to retry, and idempotent so a delayed or repeated run does not create conflicting changes.

Protect the production action

GitHub Actions environments can require approvals or other protection rules, restrict which branches may deploy, provide access to environment secrets, and record deployment history. Concurrency controls can limit simultaneous deployments to an environment. For a rollback job, use the appropriate production environment protections and a concurrency group that prevents a rollback from racing a normal deployment. Define the rollback target explicitly, such as the last known-good artifact or release, rather than relying on an ambiguous “previous” state.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

Whether a job acts automatically or waits for approval is a risk decision. Automatic action can reduce response time, but a noisy or poorly chosen health signal can trigger an unnecessary rollback. Approval adds a control point but may delay recovery. GitHub’s environment rules can gate a job; they do not determine which policy is right for a particular system.

Independent reader supportYour contribution helps us test, update, and keep practical guides available for everyone.Support on Ko-Fi

Does flipping a flag roll back a deployment?

No. A flag change alters a runtime decision for code that is already deployed. A deployment rollback restores or redeploys a code artifact. If a defect is in the deployed code, changing a flag helps only if the affected behavior is controlled by that flag and the deployed version still handles the alternate state safely.

Action What changes Use it when
Flag change The runtime choice between behaviors in deployed code. The problematic feature is safely controlled by a flag and disabling it addresses the issue.
Deployment rollback The deployed artifact or release. The code itself must be replaced with a known-good version.

Choose and document the mechanism that matches the failure: a flag update, an artifact redeployment, an alert for human action, or another explicit procedure. A scheduled trigger alone is not evidence that a rollback is warranted.

Product prices and availability are accurate as of the date/time indicated and are subject to change. Any price and availability information displayed on Amazon at the time of purchase will apply.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

Leave a Reply

Your email address will not be published. Required fields are marked *

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

More from the Wire

  1. World desk4 min
    How to Spot an AI Voice Scam Before Sending MoneyDon’t rely on how a caller sounds. Pause, call back through a known number, and verify the emergency with another trusted person before sending money.
  2. Mountain View desk4 min
    Google’s SynthID Detector: How to Check AI-Generated Images, Video and AudioGoogle’s SynthID Detector looks for an embedded watermark in supported images, video and audio. Here is what its results do—and do not—show.
  3. Redmond desk20 min
    How to create a link to File or Folder in Windows 11Windows 11 gives you several ways to point to a file or folder without moving or duplicating it. You can create a desktop shortcut,…
Recommended PC Tool
Recommended PC Tool
PC Slower Than It Used to Be?Free scan - under a minute
Crashes, No Sound, or Screen Glitches?Free driver scan

Two free Windows tools

One Free Minute Could Fix That PC

Before you go - each of these free tools takes about a minute and tackles what quietly slows a Windows PC down.

Special offer. View Outbyte info, uninstall instructions, EULA, and Privacy Policy.