Skip to main content

Feature Flag Libraries for React: LaunchDarkly vs Open Source

Choosing a feature flag system is a foundational decision: it affects how you deploy, test, and ship features for years. You have four main options: commercial services like LaunchDarkly or Statsig (expensive but full-featured), open-source projects like Unleash (free but you self-host), or build your own. This article compares options, helps you choose, and walks through setup for the most popular libraries.

In 2023, my startup used LaunchDarkly and paid 3k USD per month for flag analytics we barely used. We switched to Unleash (self-hosted), cut costs to ~500 USD per month (server), and gained features we actually needed (permission toggles, advanced targeting). But if we'd had 50+ engineers, LaunchDarkly's UI and audit logs would have justified the cost. Choose based on team size and feature maturity, not cargo cult.

Feature Comparison: LaunchDarkly vs Unleash vs Statsig vs DIY

FeatureLaunchDarklyUnleashStatsigDIY (Custom API)
Hosted/ManagedYes (SaaS)NoYesNo
Price (per month)$3,000–20k+~$500~$1,500~$500–2k
Setup time1 hour1 day1 hour2–4 weeks
Targeting (rules, segments)ExcellentGoodExcellentCustom
A/B testing / experimentationFull suiteBasicFull suiteDIY
Analytics / results reportingYesNoYesDIY
Audit logsYesYesYesDIY
SDKs (JavaScript/React)ExcellentGoodGoodCustom
Real-time updates (SSE/WebSocket)YesYesYesDIY
Data residency (EU/FedRAMP)YesYesYesYour choice
Ease of use (non-technical)HighMediumHighLow

LaunchDarkly: Best for large enterprises with strict compliance, multi-team coordination, and experimentation at scale. Expensive but minimal ops burden.

Unleash: Best for teams wanting a powerful open-source tool they can self-host. You manage the server, but Unleash handles the UI and rules engine.

Statsig: Best for product teams doing frequent A/B tests and needing built-in analytics. Mid-market sweet spot.

DIY: Best for startups with tight budgets, simple flag needs, and small teams who can own the infrastructure.

LaunchDarkly Setup for React

LaunchDarkly's React SDK is battle-tested and widely used. Setup takes 1 hour.

  1. Sign up at launchdarkly.com, create a project, and copy your SDK key.

  2. Install the SDK:

npm install launchdarkly-react-client-sdk
  1. Wrap your app in the provider:
// App.jsx
import { asyncWithLDProvider } from 'launchdarkly-react-client-sdk';

const App = await asyncWithLDProvider({
clientSideID: 'YOUR_SDK_KEY', // From LaunchDarkly dashboard
user: {
key: user.id,
email: user.email,
name: user.name,
custom: {
tier: user.tier, // Pro, Starter, etc.
region: user.region,
},
},
});

export default App;
  1. Use flags in components:
import { useFlags } from 'launchdarkly-react-client-sdk';

export function Checkout() {
const { checkout_v2, dark_mode } = useFlags();

return (
<div>
{checkout_v2 ? <CheckoutV2 /> : <CheckoutLegacy />}
{dark_mode && <style>{darkModeCSS}</style>}
</div>
);
}
  1. Define flags in the LaunchDarkly dashboard:
    • Click "Feature Flags" → "Create flag"
    • Name: checkout_v2
    • Type: Boolean (or Multivariate)
    • Rules: "If tier equals Pro, flag is on for 100%. Otherwise, flag is on for 25% of users."
    • Save and deploy.

That's it. LaunchDarkly handles all updates, analytics, and targeting. The SDK is feature-complete with no backend needed.

Unleash Setup for React

Unleash is open-source and powerful, but requires a self-hosted server. Setup is a day.

  1. Deploy Unleash server (using Docker):
docker run -d -p 4242:4242 \
-e DATABASE_URL=postgresql://user:pass@db:5432/unleash \
unleashsh/unleash:latest
  1. Access the Unleash admin UI at http://localhost:4242 (default user: admin / unleash4all).

  2. Create a feature flag:

    • Click "Create feature toggle"
    • Name: checkout_v2
    • Activation strategies: "Standard (all users)" or "Gradual rollout (X%)"
    • Enable for 10% of users
    • Save.
  3. Install the Unleash SDK for React:

npm install @unleash/proxy-client-react
  1. Wrap your app:
// App.jsx
import { FlagProvider } from '@unleash/proxy-client-react';

export function App() {
return (
<FlagProvider
config={{
url: 'https://your-unleash-server.com/client',
clientKey: 'default:development.YOUR_CLIENT_KEY',
appName: 'my-react-app',
}}
>
<Main />
</FlagProvider>
);
}
  1. Use flags in components:
import { useFlag } from '@unleash/proxy-client-react';

export function Checkout() {
const checkoutV2Enabled = useFlag('checkout_v2');

return checkoutV2Enabled ? <CheckoutV2 /> : <CheckoutLegacy />;
}

Costs: The Unleash server runs on your infrastructure (AWS, GCP, Heroku). A small t3.micro instance costs ~$10/month; a production setup with HA is ~$500/month.

DIY: Build Your Own Flag Service

For startups, a simple custom API is sufficient. You've already seen this architecture in earlier articles. Recap:

  1. Backend endpoint: GET /api/flags?userId=123 returns { "checkout_v2": true, "dark_mode": false }
  2. React context + hooks: Fetch at app startup, cache in context.
  3. Flag updates: Poll every 30 sec or use SSE.

Cost: Whatever your server infrastructure costs (usually free tier of AWS/GCP for <1k users).

Time to MVP: 2–3 weeks (API, cache logic, monitoring).

Cons: No built-in analytics, audit logs, or targeting UI. You write YAML or JSON to define rules.

Example flag config file (stored in your repo or a database):

{
"flags": [
{
"name": "checkout_v2",
"enabled": true,
"rules": [
{
"condition": { "userId": { "in": ["u123", "u456"] } },
"percentage": 100
},
{
"condition": { "tier": "Pro" },
"percentage": 100
},
{
"condition": {},
"percentage": 10
}
]
}
]
}

Your backend evaluates rules and returns the result.

Decision Matrix: Which Tool?

Choose LaunchDarkly if:

  • Team > 20 engineers
  • Need experimentation analytics built-in
  • Compliance/audit logs are mandatory
  • Budget > $3,000/month

Choose Unleash if:

  • Team 5–50 engineers
  • Want open-source with a nice UI
  • Self-hosting is acceptable
  • Willing to manage the Unleash server

Choose Statsig if:

  • Team 10–30 engineers
  • Frequent A/B testing is core
  • Need experimentation analytics
  • Budget $1,000–3,000/month

Build DIY if:

  • Team < 10 engineers
  • Simple boolean flags only (no complex targeting)
  • Low budget
  • OK with owning infrastructure and no analytics

Migration Path

Start simple, upgrade as you grow:

  1. Startup (0–1M users): DIY API or Unleash.
  2. Growth (1–10M users): Upgrade to LaunchDarkly or Statsig.
  3. Scale (>10M users): Custom solution + edge caching (LaunchDarkly edge may not be fast enough).

Key Takeaways

  • LaunchDarkly: Most complete SaaS, best for large teams with compliance needs, ~$3–20k/month.
  • Unleash: Excellent open-source alternative, self-hosted, ~$500/month operational cost.
  • Statsig: Strong mid-market option with great analytics, ~$1,500/month.
  • DIY: Cheapest, but you own everything. Only for small teams with simple needs.

Frequently Asked Questions

Can I migrate from LaunchDarkly to Unleash later?

Yes, but it's a migration project. Both have similar concepts (flags, rules, users), but the API and UI differ. You'll need to export flags from LaunchDarkly, transform the config, and import to Unleash. Plan for 2–4 weeks of work.

Does LaunchDarkly offer self-hosting?

Not the standard SaaS. They have a "Private Edition" for on-premise deployments, but it's enterprise-only and extremely expensive (six figures). Unleash is the self-hosted alternative.

Can I use multiple flag services simultaneously?

Yes. You might use LaunchDarkly for kill switches (high-critical) and Unleash for experiments (non-critical). Both SDKs can coexist in React. But this adds complexity; avoid it unless you have a specific reason.

How does flag performance affect React rendering?

Flag lookups (a context read) are O(1) and don't cause re-renders. The only cost is the initial fetch (network latency). Use HTTP caching and edge CDNs to keep latency < 50 ms. If you have thousands of flags, consider pagination or lazy-loading.

What if my flag service goes down during an incident?

Most libraries (LaunchDarkly, Unleash, DIY) cache flags on the frontend. If the service is down, users see the last-known flag state (usually still useful). For critical ops toggles, ensure aggressive caching (cache TTL = 10 min) and geographic redundancy (CDN edge caches).

Further Reading