A first party Edge Config integration with the Statsig server-side Node.js SDK.
- Install the Statsig Node SDK
npm install statsig-node@5.3.0
- Install this package and the Edge Config SDK
npm install statsig-node-vercel @vercel/edge-config
- Install the Statsig Vercel Integration
- Import the packages
import { EdgeConfigDataAdapter } from "statsig-node-vercel";
import { createClient } from "@vercel/edge-config";
- 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"
})
- 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 });