What is launchdarkly-node-server-sdk?
The launchdarkly-node-server-sdk is a feature flag management tool that allows developers to control the release of features to users. It provides a way to manage feature flags, target specific user segments, and perform A/B testing. This SDK is designed for server-side applications.
What are launchdarkly-node-server-sdk's main functionalities?
Initialize the SDK
This code initializes the LaunchDarkly client with your SDK key and waits for the client to be fully initialized before proceeding.
const LaunchDarkly = require('launchdarkly-node-server-sdk');
const client = LaunchDarkly.init('YOUR_SDK_KEY');
client.waitForInitialization().then(() => {
console.log('LaunchDarkly client initialized');
}).catch(err => {
console.error('LaunchDarkly client failed to initialize', err);
});
Evaluate a feature flag
This code evaluates a feature flag for a specific user and returns the flag's value. The default value is used if the flag is not found.
const user = { key: 'user-key-123' };
client.variation('your-feature-flag-key', user, false).then(flagValue => {
if (flagValue) {
console.log('Feature is enabled for this user');
} else {
console.log('Feature is disabled for this user');
}
});
Track custom events
This code tracks a custom event for a specific user, which can be used for analytics and A/B testing purposes.
client.track('custom-event-key', user, { customData: 'value' });
Close the client
This code gracefully shuts down the LaunchDarkly client, ensuring that all pending events are sent before closing.
client.close().then(() => {
console.log('LaunchDarkly client closed');
});
Other packages similar to launchdarkly-node-server-sdk
flagr
Flagr is another open-source feature flagging and A/B testing tool. It offers similar capabilities to LaunchDarkly, including feature flag evaluation and user targeting. Flagr is also self-hosted, requiring you to handle the deployment and maintenance of the service.
optimizely
Optimizely is a feature flagging and experimentation platform. It provides robust A/B testing and feature management capabilities. Compared to LaunchDarkly, Optimizely offers more advanced experimentation features but can be more expensive.
LaunchDarkly Server-Side SDK for Node.js
As mentioned in the repository changelog, the launchdarkly-node-server-sdk
project has been renamed to @launchdarkly/node-server-sdk
. All future releases will be made from the new repository. Please consider upgrading and filing potential requests in that repository's issue tracker.
☝️☝️☝️☝️☝️☝️
v7.x readme
The LaunchDarkly Server-Side SDK for Node.js is designed primarily for use in multi-user systems such as web servers and applications. It follows the server-side LaunchDarkly model for multi-user contexts. It is not intended for use in desktop and embedded systems applications.
For using LaunchDarkly in client-side Node.js applications, refer to our Client-side Node.js SDK.
LaunchDarkly overview
LaunchDarkly is a feature management platform that serves trillions of feature flags daily to help teams build better software, faster. Get started using LaunchDarkly today!
Supported Node versions
This version of the LaunchDarkly SDK is compatible with Node.js versions 12 and above.
Getting started
Refer to the SDK reference guide for instructions on getting started with using the SDK.
Learn more
Read our documentation for in-depth instructions on configuring and using LaunchDarkly. You can also head straight to the complete reference guide for this SDK.
The authoritative description of all properties and methods is in the TypeScript documentation.
Testing
We run integration tests for all our SDKs using a centralized test harness. This approach gives us the ability to test for consistency across SDKs, as well as test networking behavior in a long-running application. These tests cover each method in the SDK, and verify that event sending, flag evaluation, stream reconnection, and other aspects of the SDK all behave correctly.
Contributing
We encourage pull requests and other contributions from the community. Check out our contributing guidelines for instructions on how to contribute to this SDK.
About LaunchDarkly
- LaunchDarkly is a continuous delivery platform that provides feature flags as a service and allows developers to iterate quickly and safely. We allow you to easily flag your features and manage them from the LaunchDarkly dashboard. With LaunchDarkly, you can:
- Roll out a new feature to a subset of your users (like a group of users who opt-in to a beta tester group), gathering feedback and bug reports from real-world use cases.
- Gradually roll out a feature to an increasing percentage of users, and track the effect that the feature has on key metrics (for instance, how likely is a user to complete a purchase if they have feature A versus feature B?).
- Turn off a feature that you realize is causing performance problems in production, without needing to re-deploy, or even restart the application with a changed configuration file.
- Grant access to certain features based on user attributes, like payment plan (eg: users on the ‘gold’ plan get access to more features than users in the ‘silver’ plan). Disable parts of your application to facilitate maintenance, without taking everything offline.
- LaunchDarkly provides feature flag SDKs for a wide variety of languages and technologies. Read our documentation for a complete list.
- Explore LaunchDarkly