Skip to main content

Node.js SDK Getting Started

Npm package version GitHub

To use the DevCycle Server SDK in your project, import the @devcycle/nodejs-server-sdk package and call initializeDevCycle with your DevCycle SDK server key. You may optionally await for the client to be initialized.

JS Example:

const DevCycle = require('@devcycle/nodejs-server-sdk')

const devcycleClient = await DevCycle.initializeDevCycle('<DEVCYCLE_SDK_SERVER_KEY>').onClientInitialized()

Typescript Example:

import { initializeDevCycle } from '@devcycle/nodejs-server-sdk'

const devcycleClient = await initializeDevCycle('<DEVCYCLE_SDK_SERVER_KEY>').onClientInitialized()

Initialization Options

The SDK exposes various initialization options which can be set on the initialization() method:

DevCycleOptions Typescript Schema

const devcycleClient = await DevCycle.initializeDevCycle('<DEVCYCLE_SDK_SERVER_KEY>', {
configPollingIntervalMS: 60 * 1000
DevCycle OptionTypeDescription
loggerDevCycleLoggerLogger override to replace default logger
logLevelStringSet log level of the default logger. Options are: debug, info, warn, error. Defaults to info.
enableCloudBucketingBooleanSwitches the SDK to use Cloud Bucketing (via the DevCycle Bucketing API) instead of Local Bucketing.
enableEdgeDBBooleanEnables the usage of EdgeDB for DevCycle that syncs User Data to DevCycle.
NOTE: This is only available with Cloud Bucketing.
configPollingIntervalMSNumberControls the polling interval in milliseconds to fetch new environment config changes, defaults to 10 seconds, minimum value is 1 second.
configPollingTimeoutMSNumberControls the request timeout to fetch new environment config changes, defaults to 5 seconds, must be less than the configPollingIntervalMS value, minimum value is 1 second.
eventFlushIntervalMSNumberControls the interval between flushing events to the DevCycle servers, defaults to 30 seconds.
disableAutomaticEventLoggingBooleanDisables logging of sdk generated events (e.g. aggVariableEvaluated, aggVariableDefaulted) to DevCycle.
disableCustomEventLoggingBooleanDisables logging of custom events, from track() method, and user data to DevCycle.
flushEventQueueSizeNumberControls the maximum size the event queue can grow to until a flush is forced. Defaults to 1000.
maxEventQueueSizeNumberControls the maximum size the event queue can grow to until events are dropped. Defaults to 2000.
apiProxyURLStringAllows the SDK to communicate with a proxy of DevCycle bucketing API / client SDK API.