Kameleoon NodeJS SDK is used to work with Kameleoon Feature Flags and Experiments using native NodeJS api. Integration of this SDK on server is easy, and its footprint is low.
This page describes the most basic KameleoonClient configuration, for more in-depth review of all the methods and configuration options follow Official Kameleoon Documentation
- npm -
npm install @kameleoon/nodejs-sdk - yarn -
yarn add @kameleoon/nodejs-sdk - pnpm -
pnpm add @kameleoon/nodejs-sdk
- Obtain your site code from Kameleoon Platform
- Create client instance
import { KameleoonClient } from '@kameleoon/nodejs-sdk';
const client = new KameleoonClient({ siteCode: 'my_site_code' });- Asynchronously initialize client to fetch the configuration from remote server and handle possible errors
try {
await client.initialize();
} catch (error) {
// Handle error
}KameleoonClientis ready to go!
const visitorCode = KameleoonUtils.getVisitorCode({
domain: 'www.example.com',
request: req, // `NodeJS/NextJS/Deno` request object
response: res, // `NodeJS/NextJS/Deno` response object
});
const customDataIndex = 0;
// -- Add targeting data
client.addData(visitorCode, new CustomData(customDataIndex, 'my_data'));
// -- Check if the feature is active for visitor
const isMyFeatureActive = client.isFeatureFlagActive(
visitorCode,
'my_feature_key',
);