Skip to content

statsig-io/vercel-data-adapter-node

Repository files navigation

Statsig Node Server SDK - Edge Config Adapter

npm version

A first party Edge Config integration with the Statsig server-side Node.js SDK.

Quick Setup

  1. Install the Statsig Node SDK
npm install [email protected]
  1. Install this package and the Edge Config SDK
npm install statsig-node-vercel @vercel/edge-config
  1. Install the Statsig Vercel Integration
  2. Import the packages
import { EdgeConfigDataAdapter } from "statsig-node-vercel";
import { createClient } from "@vercel/edge-config";
  1. Create an instance of the EdgeConfigDataAdapter
const edgeConfigClient = createClient(process.env.EDGE_CONFIG);
const dataAdapter = new EdgeConfigDataAdapter({
  edgeConfigClient: edgeConfigClient,
  edgeConfigItemKey: "ITEM_KEY_FROM_INSTALLATION", // something like "statsig-5FSfBpWM9kUPqeKRlZPkod"
})
  1. When initializing the statsig sdk, add the adapter to options, along with the initStrategyForIDLists and disableIdListsSync options to avoid a blocking network call for ID Lists. However, if you are using Statsig ID lists for evaluation, you'll need to omit those options and incur a network request to grab ID lists.
await statsig.initialize("server-secret-key", { dataAdapter: dataAdapter, initStrategyForIDLists: 'none', disableIdListsSync: true });