Skip to content
 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

51 Commits
 
 
 
 

Repository files navigation

Kameleoon NodeJS SDK

Introduction

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

Contents

Installation

  • npm - npm install @kameleoon/nodejs-sdk
  • yarn - yarn add @kameleoon/nodejs-sdk
  • pnpm - pnpm add @kameleoon/nodejs-sdk

Configuration

  1. Obtain your site code from Kameleoon Platform
  2. Create client instance
import { KameleoonClient } from '@kameleoon/nodejs-sdk';

const client = new KameleoonClient({ siteCode: 'my_site_code' });
  1. Asynchronously initialize client to fetch the configuration from remote server and handle possible errors
try {
  await client.initialize();
} catch (error) {
  // Handle error
}
  1. KameleoonClient is 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',
);

About

No description, website, or topics provided.

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors