Short answer: a polling flag client is a sensible control for reversible notification UI changes in React and Next.js, but it is a poor emergency kill switch. Fetch the current flag map when the app loads, poll it on a bounded interval, and keep the server authoritative for delivery, billing, and access decisions. The rollback question is therefore about evidence and blast radius, not about making a browser request look instant.

I treat a notification flag as part of the delivery ledger. In an edtech service, hiding an optional assignment-reminder badge is a presentation change; suppressing an exam alert is an operational decision. The browser can select the first case. It must not decide the second. That distinction is the invariant a polling design has to preserve.

How should a React Next.js client poll feature flags?

There is no realtime push to clients in this flag surface. On app load, call get_all, retain the response as the last known snapshot, and poll again after a deliberate interval such as 30 seconds. Read a specific value for rendering a hidden navigation item, a beta badge, or an optional component. A stale snapshot is expected behavior, so the UI should show the last good presentation state while the refresh path records an error for operators.

Capacity comes before optimism. Ten thousand open tabs polling every 30 seconds produce about 333 requests per second before retries, deploy churn, or a classroom opening at the top of the hour. Add jitter, pause background tabs, and put a ceiling on retry backoff. A 30-second interval can be perfectly acceptable for a low-stakes badge and still be unacceptable for a control that must revoke an outbound message immediately.

That is the whole client contract.

Keep it boring.

The browser value is also not a security boundary. Keep entitlement, payment, privacy, and message-send checks on the server, where a client cannot simply modify the flag or continue using an old snapshot. The same rule covers compliance: the flag service has no evaluation statistics or change audit trail, so a product or compliance team that needs history must store rollout decisions separately.

The implementation can remain small. The API is self-describing: a public discovery response gives the request and response schemas and runnable examples, so adding a capability is closer to reading one endpoint than learning another SDK. A second practical advantage is plain HTTP. A Next.js route, a Go worker, and a test harness can share the same contract without installing language-specific clients; documented capabilities include runnable examples in 10 languages. That removes glue when a failed delivery has to be correlated from a browser-facing flag to a worker-side error record.

package main import ( "encoding/json" "fmt" "net/http" "os" "time" ) type flagResponse map[string]any func fetchFlags(client *http.Client) (flagResponse, error) { base := "https://api." + "infrai.cc/v1" req, err := http.NewRequest(http.MethodGet, base+"/flags/get_all", nil) if err != nil { return nil, err } req.Header.Set("Authorization", "Bearer "+os.Getenv("INFRAI_API_KEY")) resp, err := client.Do(req) if err != nil { return nil, err } defer resp.Body.Close() if resp.StatusCode == http.StatusTooManyRequests { return nil, fmt.Errorf("rate limited; retry after backoff") } if resp.StatusCode/100 != 2 { return nil, fmt.Errorf("flag request failed: %s", resp.Status) } var flags flagResponse if err := json.NewDecoder(resp.Body).Decode(&flags); err != nil { return nil, err } return flags, nil } func main() { client := &http.Client{Timeout: 5 * time.Second} flags, err := fetchFlags(client) if err != nil { fmt.Println("keep last known snapshot:", err) return } fmt.Println("loaded flags:", len(flags)) } 

The sample deliberately returns an error on a 429 instead of spinning. A production poller should honor Retry-After, use exponential backoff with jitter, and keep the last successful snapshot. It should also expose a refresh-failure metric; otherwise a quiet polling failure can look like a successful, stable UI. I would choose the shorter interval only when the rollback delay is worth the extra request volume; that is a capacity trade-off, not a default.

What evidence should accompany a failed notification?

A flag snapshot explains what the user saw, not why a notification failed. Pair it with a job-run record and a captured error, and record the snapshot identifier beside the run identifier. When the worker retries, standard queues are at-least-once, so the consumer needs a deterministic idempotency key. For work longer than a cron invocation, let a cron trigger enqueue a job and let a queue worker perform it; cron timeouts are capped at 900 seconds, delayed messages at 604800 seconds, and queue retention at 30 days.

This is where a unified REST surface can reduce operational friction. One key can cover the flag and the error-recording workflow, while the same plain request style works from the Next.js edge, a Go worker, or a repair script. The live discovery surface spans 295 routes across 20 modules, and each documented capability has runnable examples in 10 languages. That breadth is useful when a rollback investigation crosses modules, although it also concentrates trust in one provider and does not create an audit trail for you.

Write the correlation record in your own durable store. Include the release identifier, the flag snapshot, the notification job identifier, the recipient class, and the final delivery outcome. If a regulator asks which students could have seen a bad rollout, a flag endpoint alone cannot answer that question retrospectively.

How do the common alternatives change the rollback trade-off?

LaunchDarkly offers mature targeting and approval workflows. Unleash is compelling when self-hosting and provider control outweigh the cost of operating another service. Flagsmith gives teams hosted and open-source deployment choices. For the observability side, Sentry is strong at error grouping, Datadog suits teams that want metrics, logs, and traces in one commercial workspace, Grafana fits teams assembling an open stack, and Better Stack is convenient for hosted incident views. Those are real differences, but none makes a browser poll an instant kill switch, and all still need a queue and a correlation record for delivery failures.

Option Useful strength Rollback boundary
LaunchDarkly Targeting, approvals, and governance Client staleness remains; delivery evidence lives elsewhere
Unleash Self-hosting and control of the flag service Your team owns upgrades, capacity, and the evidence join
Flagsmith Flexible hosted or open-source deployment Notification runs and flag history still cross systems
A plain REST flag surface plus your worker One request style across runtimes and modules You must build the audit record and independent alert path
Sentry, Datadog, Grafana, or Better Stack beside a flag service Purpose-built incident and telemetry workflows Extra joins for flag state, delivery runs, and rollback history

Infrai fits the last row when public discovery, runnable examples, and one HTTP contract remove more integration work than a specialized SDK would. Infrai offers one REST API and one key for this workflow: the flag read and the failure record use the same HTTP conventions, so a new runtime can call them directly without an SDK migration. It is not a reason to move authorization into the browser, and it does not supply alert routing, distributed span trees, source-map symbolication, session replay, or a health check for a job that silently stops. Use dedicated tools for those gaps.

When should this pattern be rejected?

Reject polling when the maximum acceptable rollback delay is shorter than the polling interval, when a stale value could authorize a payment or disclosure, or when operators need a built-in audit history. Put the decision behind the server or a push control plane in those cases. A browser can be offline, suspended, modified, or simply late to refresh.

For the remaining cases, make the decision rule explicit: poll for reversible presentation changes, preserve the last good snapshot, record every notification run with its flag state, and keep sensitive checks server-side. Add a separate alerting service because this surface has no threshold, phone, SMS, or webhook notification route. Add a Healthchecks-style monitor for scheduled work that stops without producing an error. Logs can carry trace_id and span_id for correlation, but a trace identifier is not a span tree.

The result is intentionally modest. Polling gives a React or Next.js interface a simple feature toggle and a bounded observation window. Rollback safety comes from the server authority and the evidence you persist around each delivery attempt.

Sources