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 JavaScript SDK

Was this page helpful?
Previous

Set up Node.js (client-side) SDK

Next
Built with
Read docsAutomate in Cursor

Install the package

$yarn add @launchdarkly/js-client-sdk

Initialize the SDK

JavaScript SDK initialization
1// A "context" is a data object representing users, devices, organizations, and
2// other entities. You'll need this later, but you can ignore it for now.
3const context = {
4 kind: 'user',
5 key: 'EXAMPLE_CONTEXT_KEY'
6};
7// This is your client-side ID.
8const client = createClient('YOUR_CLIENT_SIDE_ID', context);
9client.start();
10
11const { status } = await client.waitForInitialization();
12
13if (status === 'complete') {
14 console.log('SDK successfully initialized!');
15} else {
16 console.error('Initialization failed');
17}
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 JavaScript SDK reference guide.