What is @launchdarkly/node-server-sdk?
@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, perform A/B testing, and roll out new features gradually.
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');
});
Evaluate a feature flag
This code evaluates a feature flag for a given user and returns the flag's value. It allows you to control feature access on a per-user basis.
const user = { key: 'user-key' };
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 custom events, which can be useful for analytics and understanding user behavior.
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 a web UI for managing flags and supports complex flag evaluation rules. Like Unleash, Flagr is self-hosted, providing flexibility and control at the cost of additional maintenance.
splitio
Split.io is a feature flagging and experimentation platform. It offers robust analytics and targeting capabilities, similar to LaunchDarkly. Split.io is a managed service, which means less maintenance for the user but potentially higher costs.
LaunchDarkly Server-Side SDK for Node.js
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 14 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.
Verifying SDK build provenance with the SLSA framework
LaunchDarkly uses the SLSA framework (Supply-chain Levels for Software Artifacts) to help developers make their supply chain more secure by ensuring the authenticity and build integrity of our published SDK packages. To learn more, see the provenance guide.
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. Check out our documentation for a complete list.
- Explore LaunchDarkly