This topic describes how to install the LaunchDarkly developer toolbar. You can install and configure the toolbar directly in your codebase, and use it in your browser during local development.
You should use the toolbar only in a local dev environment. Do not render it in hosted or production environments.
Depending on your package manager, install the toolbar package using one of the following methods:
npm
npm install @launchdarkly/toolbar@latest
yarn
yarn add @launchdarkly/toolbar@latest
pnpm
pnpm add @launchdarkly/toolbar@latest
Then, install the developer toolbar using one of the following methods:
React
Vue
Angular
using a CDN
The Developer Toolbar depends on your LaunchDarkly JavaScript client having a reference to the same FlagOverridePlugin and EventInterceptionPlugin that you pass into the developer toolbar. Be sure that that you instantiate the toolbar at the same time or immediately after you initiate the client.
If you develop your front end using React, the @launchdarkly/toolbar package provides a React hook to configure and lazily-load the developer toolbar.After you install the package, navigate to the area of your application where you instantiate your LaunchDarkly React client. The developer toolbar uses two plugins to power its functionality, and those plugins also need to be passed into the LaunchDarkly React client.To do this:
Pass plugins to the client
import { render } from 'react-dom'; import { asyncWithLDProvider } from 'launchdarkly-react-client-sdk'; import { useLaunchDarklyToolbar, FlagOverridePlugin, EventInterceptionPlugin } from '@launchdarkly/toolbar'; // Pass the same instance of these plugins into both the LaunchDarkly // React client as well as the developer toolbar const flagOverridePlugin = new FlagOverridePlugin(); const eventInterceptionPlugin = new EventInterceptionPlugin(); (async () => { const LDProvider = await asyncWithLDProvider({ clientSideID: 'example-client-side-id', context: { kind: 'user', key: 'example-user-key', name: 'Sandy Smith', email: 'sandy@example.com', }, options: { plugins: [ flagOverridePlugin, eventInterceptionPlugin, // other plugins... ], // other options... }, }); function App() { // Initialize toolbar with the same plugin instances useLaunchDarklyToolbar({ flagOverridePlugin, // For flag overrides (SDK Mode only) eventInterceptionPlugin, // For event monitoring (works in both modes) // OR Dev Server Mode: Connect to LaunchDarkly dev server devServerUrl: 'http://localhost:8080', projectKey: 'my-project', // Optional: auto-detects if not provided // Common options position: 'bottom-right', enabled: process.env.NODE_ENV === 'development' // disable in production/hosted environments }); return <YourApp />; } render( <LDProvider> <App /> </LDProvider>, document.getElementById('root'), ); })();
If you are not using React, Vue, or Angular as your front-end framework, or want to use the developer toolbar in a way where it is decoupled from your tech stack and its dependencies, you can also instantiate the toolbar using a CDN.To do so, add this script to your index.html file:
This attaches LaunchDarklyToolbar to your window and exposes an init() method using window.LaunchDarklyToolbar.init() that will lazily load the developer toolbar in the same way the React hook does.In your corresponding code, wherever you instantiate your LaunchDarkly JavaScript client, pass in the following plugins:
Pass plugins to the client
import * as LDClient from 'launchdarkly-js-client-sdk'; import { FlagOverridePlugin, EventInterceptionPlugin } from '@launchdarkly/toolbar'; // Pass these plugins into both the JS client and // the window.LaunchDarklyToolbar.init() call. const flagOverridePlugin = new FlagOverridePlugin(); const eventInterceptionPlugin = new EventInterceptionPlugin(); const context: LDClient.LDContext = { kind: 'user', key: 'example-context-key', }; const client = LDClient.initialize('example-client-side-id', context, { plugins: [ flagOverridePlugin, eventInterceptionPlugin, // other plugins... ], // other options... }); try { await client.waitForInitialization(5); // initialization succeeded, flag values are now available handleInitializedClient(client); } catch (err) { // initialization failed or did not complete before timeout } // Only initialize the toolbar in local environments if (process.env.NODE_ENV === 'development' && window.LaunchDarklyToolbar) { window.LaunchDarklyToolbar.init({ flagOverridePlugin, eventInterceptionPlugin, // other toolbar options... }); }
If you are using TypeScript and want type-safety for the window.LaunchDarklyToolbar.init call, you can add a window.d.ts file to the root of your web application with the following:
Add a window.d.ts file
import type { LaunchDarklyToolbar } from '@launchdarkly/toolbar'; declare global { interface Window { LaunchDarklyToolbar?: LaunchDarklyToolbar; } }
The developer toolbar supports running in two different modes:
SDK mode: Integrates with your LaunchDarkly SDK for local flag overrides and testing
Dev server mode: Connects to a LaunchDarkly CLI dev server for flag browsing and real-time updates
SDK mode is the default mode for the toolbar. The toolbar switches to dev server mode only if you provide devServerUrl. Generally, we recommend SDK mode.
| --- |
| SDK mode| Flag overrides (if you provide flagOverridePlugin) Events (if you provide eventInterceptionPlugin) Settings |
| Dev server mode| Flags Settings |