Experimentation Lab
Interactive implementation reference
Feature SDK implementation

JavaScript Browser v5

The pre-v6 browser-specific SDK, retained to demonstrate legacy implementations.

Browser · legacy
This runtime cannot execute inside a Next.js browser process. The page shows the native, official SDK shape; use the JavaScript, React, or Next.js pages for a live decision and event round trip with the same project, flag, event, and visitor ID.

Implementation

Official docs ↗
npm install @optimizely/optimizely-sdk@5
const client = createInstance({ sdkKey: 'YOUR_SDK_KEY' });
await client.onReady();
const user = client.createUserContext('visitor-123');
const decision = user.decide('demo_flag');
user.trackEvent('demo_purchase');