Integrations
Node

Node.js

Our Node.js package allows you to use Abby within all server-side applications. If you're using Node < 18 you will need to also install any fetch polyfill.

Installation

To get started make sure to install the packages using your favorite package manager.

npm i @tryabby/node

Usage

Create your config

To use Abby you need to create your config first. You can do this by creating a file called abby.config.ts in your root folder. This file will be used to configure your project.

// abby.config.ts
import { defineConfig } from "@tryabby/node";
 
export default defineConfig({
  projectId: "<YOUR_PROJECT_ID>",
  currentEnvironment: environment.production ? "production" : "development",
  environments: ["production", "development"],
  tests: {
    test: { variants: ["A", "B"] },
    footer: { variants: ["dark", "orange", "green"] },
    // ... your tests
  },
  flags: ["darkMode", "newFeature"],
  remoteConfig: {
    customButtonText: "String",
    maxSessionCount: "Number",
  },
});

Create your Abby instance

To use Abby in your code you need to call the createAbby function

import { createAbby } from "@tryabby/node";
import abbyConfig from "../abby.config";
 
export const abby = createAbby(abbyConfig);

Using Abby in your code

You can now use Abby in your code.

💡

Before you're trying to read Feature Flags, Remote Configs or A/B Test you should call the .loadProjectData() function. This retrieves all the needed information from our API. If you don't call it fallbacks will be used.

Feature Flags

You can call the getFeatureFlag function to get the value of a feature flag. Since you loaded all the information from our API this is a synchronous function.

if (abby.getFeatureFlag("newFeature")) {
  // use new algorithm
} else {
  // use old algorithm
}

Remote Configs

You can call the getRemoteConfig function to get the value of a remote config.

const maxSessionCount = abby.getRemoteConfig("maxSessionCount");
 
if (sessionCount < maxSessionCount) {
  // show session
} else {
  // show error
}

A/B Tests

You can call the getTestVariant function to get the variant of a test.

const testVariant = abby.getTestVariant("test");
 
if (testVariant === "A") {
  // show variant A
} else {
  // show variant B
}