{"id":12074,"library":"statsig-node-vercel","title":"Statsig Edge Config Adapter for Node.js","description":"This package, `statsig-node-vercel`, provides a first-party integration between the Statsig server-side Node.js SDK and Vercel's Edge Config. It allows developers to store and retrieve Statsig configuration, including feature gates, dynamic configs, and ID lists, directly from Vercel Edge Config, leveraging its low-latency, globally distributed data store. The current stable version is 0.8.1, and its release cadence appears to be tied to updates in the main Statsig Node.js SDK and Vercel's Edge Config features, with a focus on optimization and direct data parsing. Key differentiators include seamless integration with Vercel infrastructure, reduced network latency for Statsig evaluations by utilizing Edge Config, and specific optimizations for ID list handling. It significantly streamlines the deployment and management of Statsig configurations within Vercel environments.","status":"active","version":"0.8.1","language":"javascript","source_language":"en","source_url":"https://github.com/statsig-io/vercel-data-adapter-node","tags":["javascript","typescript"],"install":[{"cmd":"npm install statsig-node-vercel","lang":"bash","label":"npm"},{"cmd":"yarn add statsig-node-vercel","lang":"bash","label":"yarn"},{"cmd":"pnpm add statsig-node-vercel","lang":"bash","label":"pnpm"}],"dependencies":[{"reason":"Core Statsig Node.js SDK for server-side feature evaluation.","package":"statsig-node","optional":false},{"reason":"Required to interact with Vercel Edge Config for data storage.","package":"@vercel/edge-config","optional":false}],"imports":[{"note":"Primarily designed for ESM environments; CommonJS `require` might work with transpilation but isn't the idiomatic import.","wrong":"const { EdgeConfigDataAdapter } = require('statsig-node-vercel');","symbol":"EdgeConfigDataAdapter","correct":"import { EdgeConfigDataAdapter } from 'statsig-node-vercel';"},{"note":"This is an import from the peer dependency `@vercel/edge-config`, crucial for initializing the Edge Config client.","wrong":"const { createClient } = require('@vercel/edge-config');","symbol":"createClient","correct":"import { createClient } from '@vercel/edge-config';"},{"note":"The main Statsig SDK is typically imported as a default export `statsig` (or `Statsig` if using a different casing convention).","wrong":"import { StatsigServer } from 'statsig-node';","symbol":"StatsigServer","correct":"import statsig from 'statsig-node';"}],"quickstart":{"code":"import { EdgeConfigDataAdapter } from 'statsig-node-vercel';\nimport { createClient } from '@vercel/edge-config';\nimport statsig from 'statsig-node';\n\nasync function initializeStatsigWithVercel() {\n  const edgeConfigClient = createClient(process.env.EDGE_CONFIG_CONNECTION_STRING ?? '');\n  \n  if (!process.env.EDGE_CONFIG_CONNECTION_STRING) {\n    console.error('EDGE_CONFIG_CONNECTION_STRING is not set. Please configure your Vercel Edge Config.');\n    return;\n  }\n\n  const dataAdapter = new EdgeConfigDataAdapter({\n    edgeConfigClient: edgeConfigClient,\n    edgeConfigItemKey: process.env.STATSIG_EDGE_CONFIG_ITEM_KEY ?? 'statsig-ITEM_KEY',\n  });\n\n  if (!process.env.STATSIG_SERVER_SECRET_KEY) {\n    console.error('STATSIG_SERVER_SECRET_KEY is not set. Please provide your Statsig server secret key.');\n    return;\n  }\n\n  await statsig.initialize(process.env.STATSIG_SERVER_SECRET_KEY, {\n    dataAdapter: dataAdapter,\n    // These options are recommended for optimal performance with Edge Config\n    // to avoid blocking network calls for ID Lists on initialization.\n    // Omit if you need ID list evaluation immediately on init.\n    initStrategyForIDLists: 'none',\n    disableIdListsSync: true\n  });\n\n  console.log('Statsig initialized successfully with Vercel Edge Config!');\n\n  // Example: Check a feature gate\n  const user = { userID: 'test-user-123' };\n  const gateResult = await statsig.checkGate(user, 'a_feature_gate');\n  console.log(`Feature gate 'a_feature_gate' for user ${user.userID}: ${gateResult}`);\n\n  statsig.shutdown();\n}\n\ninitializeStatsigWithVercel().catch(console.error);","lang":"typescript","description":"This quickstart demonstrates how to initialize the Statsig Node.js SDK using the Vercel Edge Config adapter, showing setup, environment variable usage, and a basic feature gate check."},"warnings":[{"fix":"Remove any manual `JSON.stringify` or `JSON.parse` calls when interacting with data fetched via `EdgeConfigDataAdapter`. The adapter handles object serialization/deserialization automatically.","message":"The `0.4.0` release removed the need for manual JSON stringification/parsing. Previously, users might have manually `JSON.stringify` values before passing them to the adapter or `JSON.parse` values received. This is no longer necessary, as the adapter now directly passes object values.","severity":"breaking","affected_versions":">=0.4.0"},{"fix":"Ensure `initStrategyForIDLists: 'none'` and `disableIdListsSync: true` are included in the Statsig initialization options. If immediate ID list evaluation is critical on startup, consider the performance implications or pre-warm your Edge Config.","message":"When using `EdgeConfigDataAdapter`, it is recommended to set `initStrategyForIDLists: 'none'` and `disableIdListsSync: true` in the Statsig SDK initialization options. Omitting these will cause a blocking network call to fetch ID lists during initialization, potentially impacting cold start performance.","severity":"gotcha","affected_versions":">=0.1.0"},{"fix":"Double-check that the `edgeConfigItemKey` provided to `EdgeConfigDataAdapter` precisely matches the key generated during the Statsig Vercel Integration installation in your Vercel project settings (e.g., 'statsig-5FSfBpWM9kUPqeKRlZPkod').","message":"The `edgeConfigItemKey` is a crucial identifier linking your adapter to the correct item in Vercel Edge Config. A misconfigured key will result in the adapter failing to fetch Statsig data.","severity":"gotcha","affected_versions":">=0.1.0"}],"env_vars":null,"last_verified":"2026-04-19T00:00:00.000Z","next_check":"2026-07-18T00:00:00.000Z","problems":[{"fix":"Set the `EDGE_CONFIG_CONNECTION_STRING` environment variable in your Vercel project or local development environment. This string is provided by Vercel for your Edge Config.","cause":"The `@vercel/edge-config` client could not be initialized because the `EDGE_CONFIG_CONNECTION_STRING` environment variable was not found.","error":"Error: Missing Edge Config connection string. Make sure to set EDGE_CONFIG_CONNECTION_STRING in your environment variables."},{"fix":"Verify that the `edgeConfigItemKey` passed to `EdgeConfigDataAdapter` is correct and that the Statsig Vercel Integration has been successfully installed and populated data into your Edge Config instance.","cause":"The `EdgeConfigDataAdapter` was initialized with an `edgeConfigItemKey` that does not correspond to any valid Statsig data item within your Vercel Edge Config.","error":"Statsig data not found in Edge Config for key: [YOUR_ITEM_KEY]"},{"fix":"Ensure `import statsig from 'statsig-node';` is at the top of your file and that `await statsig.initialize()` is called before any other Statsig functions.","cause":"The `statsig` object was undefined, indicating the `statsig-node` SDK was not correctly imported or initialized before being used.","error":"TypeError: Cannot read properties of undefined (reading 'initialize')"}],"ecosystem":"npm"}