For AI agents: a documentation index is available at the root level at /llms.txt and /llms-full.txt. Append /llms.txt to any URL for a page-level index, or .md for the markdown version of any page.
Sign inTry it free
DocsGuidesSDKsIntegrationsAPI docsTutorialsFlagship blog
DocsGuidesSDKsIntegrationsAPI docsTutorialsFlagship blog
  • Get started
    • Overview
    • Onboarding
      • Set up .NET (server-side) SDK
      • Set up Android SDK
      • Set up Go SDK
      • Set up iOS SDK
      • Set up Java SDK (server-side)
      • Set up JavaScript SDK
      • Set up Node.js (client-side) SDK
      • Set up Node.js (server-side) SDK
      • Set up Python SDK
      • Set up React Native SDK
      • Set up React Web SDK
      • Set up Vue SDK
    • Get started
    • Launch Insights
    • LaunchDarkly architecture
    • LaunchDarkly vocabulary
  • AgentControl
    • AgentControl
    • Manage AgentControl
  • Feature flags
    • Create flags
    • Target with flags
    • Flag templates
    • Manage flags
    • Code references
    • Contexts
    • Segments
  • Releases
    • Releasing features with LaunchDarkly
    • Release policies
    • Percentage rollouts
    • Progressive rollouts
    • Guarded rollouts
    • Feature monitoring
    • Release pipelines
    • Engineering insights
    • Release management tools
    • Applications and app versions
    • Change history
    • Restoring previous flag versions
  • Observability
    • Observability
    • Session replay
    • Error monitoring
    • Logs
    • Traces
    • Observability metrics
    • Product analytics events
    • LLM observability
    • Alerts
    • Dashboards
    • Service map
    • Vega for auto-remediation
    • Observability MCP server
    • Search specification
    • Observability settings
    • Observability integrations
  • Experimentation
    • Experimentation
    • Experiment metric types
    • Experiment configuration
    • Managing experiments
    • Analyzing experiments
    • Multi-armed bandits
    • Holdouts
  • Metrics and events
    • Metrics in LaunchDarkly
    • Creating metrics
    • Metric groups
    • Events
    • Autogenerated metrics
  • Warehouse native
    • Warehouse native metrics
    • Setting up external warehouses
    • Creating experiments using warehouse native metrics
  • Infrastructure
    • Connect apps and services to LaunchDarkly
    • LaunchDarkly in China and Pakistan
    • LaunchDarkly in the European Union (EU)
    • LaunchDarkly in federal environments
    • Public IP list
  • Your account
    • Projects
    • Views
    • Environments
    • Tags
    • Teams
    • Members
    • Roles
    • Account security
    • Feature previews
    • Billing and usage
    • Changelog
Sign inTry it free
LogoLogo
On this page
  • Install the package
  • Initialize the SDK
Get startedOnboarding

Set up React Web SDK

Was this page helpful?
Previous

Set up Vue SDK

Next
Built with
LaunchDarkly onboarding is not available in federal environments
To learn more, read LaunchDarkly in federal environments.
Read docsAutomate in Cursor

Install the package

$yarn add launchdarkly-react-client-sdk

Initialize the SDK

React Web SDK initialization
1// Add the code below to the root of your React app.
2import { StrictMode } from 'react';
3import { createRoot } from 'react-dom/client';
4import { LDProvider } from 'launchdarkly-react-client-sdk';
5
6function App() {
7 return <div>Let your feature flags fly!</div>
8}
9
10// A "context" is a data object representing users, devices, organizations, and other entities.
11const context = {
12 kind: 'user',
13 key: 'EXAMPLE_CONTEXT_KEY',
14 email: 'biz@face.dev',
15};
16
17// This is your client-side ID.
18createRoot(document.getElementById('root') as HTMLElement).render(
19 <StrictMode>
20 <LDProvider clientSideID="YOUR_CLIENT_SIDE_ID" context={context}>
21 <App />
22 </LDProvider>
23 </StrictMode>,
24);
Finding your SDK credentials

You can find your server-side SDK keys, mobile keys, and client-side ID on the SDK keys page under Settings.

To learn more, read Initialize the client in the React Web SDK reference guide.