Product
Socket Now Supports uv.lock Files
Socket now supports uv.lock files to ensure consistent, secure dependency resolution for Python projects and enhance supply chain security.
launchdarkly-js-client-sdk
Advanced tools
The launchdarkly-js-client-sdk is a JavaScript SDK for LaunchDarkly, a feature management platform that allows developers to control the release of features to users. This SDK enables you to manage feature flags, perform A/B testing, and roll out new features gradually.
Initialize the client
This code initializes the LaunchDarkly client with your environment key and a user object. The client is ready to be used once the 'ready' event is fired.
const LDClient = require('launchdarkly-js-client-sdk');
const client = LDClient.initialize('YOUR_ENVIRONMENT_KEY', { key: 'user_key' });
client.on('ready', () => {
console.log('LaunchDarkly client is ready');
});
Evaluate feature flags
This code evaluates a feature flag and returns its value. If the feature flag is enabled, it will log 'Feature is enabled'; otherwise, it will log 'Feature is disabled'.
client.on('ready', () => {
const showFeature = client.variation('your-feature-flag-key', false);
if (showFeature) {
console.log('Feature is enabled');
} else {
console.log('Feature is disabled');
}
});
Track custom events
This code tracks a custom event with a specified key and optional data. This can be useful for analytics and monitoring user interactions.
client.track('custom-event-key', { customData: 'value' });
Identify users
This code identifies a new user with a unique key and optional attributes. This is useful for targeting specific users with feature flags.
client.identify({ key: 'new_user_key', name: 'New User' }).then(() => {
console.log('User identified');
});
Unleash is an open-source feature management solution. The unleash-client package provides similar functionality to LaunchDarkly, allowing you to manage feature flags and control feature rollouts. However, Unleash is self-hosted, which means you need to manage the infrastructure yourself.
ConfigCat is a feature flag and configuration management service. The configcat-js package allows you to manage feature flags and configurations in your JavaScript applications. ConfigCat offers a hosted solution with a user-friendly interface, similar to LaunchDarkly.
Flagsmith is an open-source feature flag and remote config service. The flagsmith package provides similar functionality to LaunchDarkly, including feature flag management and user targeting. Flagsmith can be used as a hosted service or self-hosted, offering flexibility in deployment.
This file contains the launchdarkly-js-client-sdk
package, which is the standard interface for the LaunchDarkly SDK for browser JavaScript. It is described in the main README.
This package automatically imports launchdarkly-js-sdk-common
, which provides much of the underlying implementation.
[2.14.0] - 2019-10-10
LDClient.track()
.createConsoleLogger()
function now has an optional second parameter for customizing the log prefix.launchdarkly-react-client-sdk
package is no longer part of this monorepo. It is now in its own repository, react-client-sdk
. Future updates to the LaunchDarkly React interface will be tracked there.Note that the React SDK code has moved to its own repository, react-client-sdk
. The 2.13.0 release was the last one that had the React wrapper code in the same repository, and from this point on the React package will be versioned separately.
FAQs
LaunchDarkly SDK for JavaScript
The npm package launchdarkly-js-client-sdk receives a total of 319,670 weekly downloads. As such, launchdarkly-js-client-sdk popularity was classified as popular.
We found that launchdarkly-js-client-sdk demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Product
Socket now supports uv.lock files to ensure consistent, secure dependency resolution for Python projects and enhance supply chain security.
Research
Security News
Socket researchers have discovered multiple malicious npm packages targeting Solana private keys, abusing Gmail to exfiltrate the data and drain Solana wallets.
Security News
PEP 770 proposes adding SBOM support to Python packages to improve transparency and catch hidden non-Python dependencies that security tools often miss.