Developer Toolbar

View as Markdown

The Unleash Developer Toolbar lets you override feature flag values and context properties at runtime without making server changes. It’s designed for local development and testing workflows where you need to quickly test different flag configurations or context values.

The Unleash Developer Toolbar showing flag overrides and context settings

Key features

  • Flag overrides: Force boolean flags on or off, or select specific variant values
  • Context overrides: Modify userId, sessionId, and custom properties to test targeting rules
  • Persistence: Choose between memory, session, or local storage for your overrides
  • Framework support: Works with React, Next.js, Vue, Angular, and JavaScript
  • SSR support: Cookie-based state sync for server-side rendering in Next.js

The toolbar is intended for development and testing environments only. Don’t use it in production unless you’re building a public demo where users interact with feature flags without Unleash access.

Installation

Choose the installation command for your framework:

$npm install @unleash/toolbar unleash-proxy-client

Import the CSS file to load the toolbar styles:

1import '@unleash/toolbar/toolbar.css';

Quickstart

The initUnleashToolbar function wraps your UnleashClient and returns a client with the same API. Use the wrapped client for all flag evaluations.

1import { initUnleashToolbar } from '@unleash/toolbar';
2import { UnleashClient } from 'unleash-proxy-client';
3import '@unleash/toolbar/toolbar.css';
4
5const client = initUnleashToolbar(new UnleashClient({
6 url: 'https://your-unleash.com/api/frontend',
7 clientKey: 'your-frontend-token',
8 appName: 'my-app'
9}), {
10 storageMode: 'local',
11 position: 'bottom-right'
12});
13
14await client.start();
15
16// Use the wrapped client for flag checks
17const isEnabled = client.isEnabled('my-feature');
18const variant = client.getVariant('my-experiment');
19
20// Listen for changes from toolbar or SDK updates
21client.on('update', () => {
22 const newValue = client.isEnabled('my-feature');
23 updateUI(newValue);
24});

View the complete JavaScript example on GitHub

Configuration options

OptionTypeDefaultDescription
storageMode'memory' | 'session' | 'local''local'Where to persist overrides. local survives browser restarts, session clears when tab closes, memory clears on reload.
storageKeystring'unleash-toolbar-state'Storage key for persistence.
position'top-left' | 'top-right' | 'bottom-left' | 'bottom-right' | 'left' | 'right''bottom-right'Toolbar button position.
initiallyVisiblebooleanfalseWhether the toolbar panel is open on load.
sortAlphabeticallybooleanfalseSort flags alphabetically instead of by evaluation order.
themePreset'light' | 'dark''light'Color theme preset.
themeobject-Custom theme with primaryColor, backgroundColor, textColor, borderColor, fontFamily.
containerHTMLElementdocument.bodyDOM element to render the toolbar into.
enableCookieSyncbooleanfalseEnable cookie sync for SSR frameworks like Next.js.

Storage modes explained

  • local (recommended for development): Persists across all tabs and browser restarts. Set overrides once, test everywhere.
  • session: Persists within the current tab only. Useful for testing different configurations in multiple tabs simultaneously.
  • memory: No persistence. Clears on every page reload. Use for quick one-off tests.

API reference

Access the toolbar instance via window.unleashToolbar:

1const toolbar = window.unleashToolbar;
2
3// Show/hide the toolbar panel
4toolbar.show();
5toolbar.hide();
6
7// Get current state
8const state = toolbar.getState();
9
10// Set flag overrides
11toolbar.setFlagOverride('my-feature', { type: 'flag', value: true });
12toolbar.setFlagOverride('my-variant', { type: 'variant', variantKey: 'variant-b' });
13toolbar.setFlagOverride('my-feature', null); // Clear override
14
15// Set context overrides
16toolbar.setContextOverride({
17 userId: 'test-user-123',
18 properties: { tier: 'premium' }
19});
20
21// Reset all overrides
22toolbar.resetOverrides();
23toolbar.resetContextOverrides();
24
25// Clean up
26toolbar.destroy();

Next.js server utilities

1import {
2 applyToolbarOverrides,
3 applyToolbarOverridesToToggles,
4 getToolbarStateFromCookies
5} from '@unleash/toolbar/next/server';
6
7// Apply overrides to definitions before evaluation (recommended)
8const modifiedDefinitions = applyToolbarOverrides(definitions, cookieStore);
9
10// Apply overrides to toggles after evaluation (alternative)
11const modifiedToggles = applyToolbarOverridesToToggles(toggles, cookieStore);
12
13// Read toolbar state directly from cookies
14const state = getToolbarStateFromCookies(cookieStore);

Bundle size

The toolbar is optimized for minimal impact:

PackageSize (gzipped)
Core~8 KB
React wrapper~0.2 KB
Next.js utilities~0.6 KB
CSS~2.4 KB

Requirements

  • Browser: ES2020 support (Chrome 90+, Firefox 88+, Safari 14+)
  • SDK versions:
    • unleash-proxy-client ^3.0.0
    • @unleash/proxy-client-react ^5.0.0 (optional)
    • @unleash/nextjs ^1.0.0 (optional)

Troubleshooting

Make sure you’ve imported the CSS file:

1import '@unleash/toolbar/toolbar.css';

Check that you’re using the wrapped client returned by initUnleashToolbar(), not the original client.

Check your storageMode setting. If set to 'memory', overrides clear on page reload. Use 'local' for persistent overrides across sessions.

For Next.js SSR, ensure you’re using applyToolbarOverrides() in your server components and that enableCookieSync is enabled in your toolbar options.

The wrapped client emits 'update' events when overrides change. If you’re using a custom setup, make sure you’re listening to these events and triggering re-renders.