Skip to content
FlagPilot
Menu

Node SDK

on

Subscribe to ready, update, error and stream state events.

ready fires with the version of the first snapshot; update with the version of every snapshot it accepts, the first one included; error with each fetch, key or snapshot error; streamStateChange with up or down when the optional SSE stream connects or drops.

Returns the client, so calls chain.

Signature
on(event: 'ready' | 'update' | 'error' | 'streamStateChange', fn): this
Example
flags.on('update', (snapshotVersion) => console.log('flags at', snapshotVersion));
flags.on('error', (err) => console.warn(err.message));

The SDK is @rollkit/sdk in the repository (packages/sdk). It is for server-side Node; browsers use a client key with the delivery API.