@featbit/openfeature-provider-node-server

中文文档
1.4.1发布于 2026/11/04ISCTypeScriptCommonJS零依赖近 30 天下载 5.1万

A OpenFeature provider implementation for the FeatBit node SDK

原始使用文档
文档目录6 节
  1. Introduction
  2. Tracking
  3. Supported Node versions
  4. Getting started
  5. Installation
  6. Quick start

FeatBit OpenFeature provider for Node.js SDK

Introduction

This is the OpenFeature provider for the Node.js Server-Side SDK for the 100% open-source feature flags management platform FeatBit.

The FeatBit OpenFeature provider is designed primarily for use in multi-user systems such as web servers and applications. It is not intended for use in desktop and embedded systems applications.

Tracking

After registering and initializing the provider, use the OpenFeature client to track events:

const client = OpenFeature.getClient();
const context = { targetingKey: 'user-123' };

client.track('page-view', context);
client.track('purchase', context, { value: 99.9 });

Tracking uses the same context-to-user mapping as flag evaluations, including targetingKey (or the legacy key), name, and custom user attributes. OpenFeature merges context before passing it to the provider, so a user key set on the client or global context can also be used. The optional value is passed to FeatBit as the numeric metric value; when omitted, the FeatBit SDK defaults it to 1. A value of 0 is preserved. Other tracking event details are ignored because the FeatBit SDK only supports a numeric metric value.

track returns void and does not need to be awaited. Events are delivered by the FeatBit SDK's event processor. Call await OpenFeature.close() at application shutdown to flush pending events and release resources.

Supported Node versions

This version of the FeatBit OpenFeature provider is compatible with Node.js versions 16 and above.

Getting started

Installation

npm install @openfeature/server-sdk
npm install @featbit/node-server-sdk
npm install @featbit/openfeature-provider-node-server

Quick start

import { OpenFeature, ProviderEvents } from '@openfeature/server-sdk';
import { FbProvider } from '@featbit/openfeature-provider-node-server';

const provider = new FbProvider({
    sdkKey: '<your-sdk-key>',
    streamingUri: '<your-streaming-uri>',
    eventsUri: '<your-events-uri>'
});

OpenFeature.setProvider(provider);

// If you need access to the FbClient, then you can use provider.getClient()

// Evaluations before the provider indicates it is ready may get default values with a
// CLIENT_NOT_READY reason.
OpenFeature.addHandler(ProviderEvents.Ready, (eventDetails) => {
    console.log(`Changed ${eventDetails.flagsChanged}`);
});


// The FeatBit provider supports the ProviderEvents.ConfigurationChanged event.
// The provider will emit this event for any flag key that may have changed (each event will contain
// a single key in the `flagsChanged` field).
OpenFeature.addHandler(ProviderEvents.ConfigurationChanged, async (eventDetails) => {
    const client = OpenFeature.getClient();
    const value = await client.getBooleanValue('ff1', false, {targetingKey: 'my-key'});
    console.log({...eventDetails, value});
});

// (async () => {
//     // When the FeatBit provider is closed it will flush the events on the FbClient instance.
//     // This can be useful for short lived processes.
//     await OpenFeature.close();
// })();

版本与发布记录

@featbit/openfeature-provider-node-server 共发布 10 个版本,首次发布于 2024/01/09;过去 12 个月发布了 6 个版本。

版本发布日期距今
1.4.1latest2026/11/0410 天前
1.4.02026/10/3114 天前
1.3.22026/10/091 个月前
1.3.12026/08/172 个月前
1.2.22026/02/049 个月前
1.2.12026/01/289 个月前

关于 @featbit/openfeature-provider-node-server 的常见问题

@featbit/openfeature-provider-node-server 是什么?

A OpenFeature provider implementation for the FeatBit node SDK

如何安装 @featbit/openfeature-provider-node-server?

在项目目录运行 npm install @featbit/openfeature-provider-node-server,或使用 pnpm add / yarn add / bun add。它还需要宿主项目提供 peer 依赖:@openfeature/server-sdk(^1.20.0)、@featbit/node-server-sdk(^1.4.1)。npm 7 及以上与 pnpm 8 及以上默认会自动安装必需的 peer 依赖,Yarn 需要手动安装。

@featbit/openfeature-provider-node-server 支持 TypeScript 吗?

支持。包内自带 TypeScript 类型声明(package.json 声明了 types 入口),安装后即可获得类型提示,无需再安装 @types 包。

@featbit/openfeature-provider-node-server 支持 ESM 还是 CommonJS?

以 CommonJS 形式发布,可以直接 require();在 ES Module 项目中也可以用 import 引入(Node.js 会把 module.exports 作为默认导出)。

@featbit/openfeature-provider-node-server 可以商用吗?

@featbit/openfeature-provider-node-server 使用 ISC 许可。宽松许可:允许商业使用、修改和再分发,通常只需在分发时保留原版权与许可声明。以上为概括,不构成法律意见,请以许可原文为准。

@featbit/openfeature-provider-node-server 的下载量有多少?

根据 npm 官方下载统计,@featbit/openfeature-provider-node-server 在 2026/10/15 – 2026/11/13 这 30 天内被下载 50,819 次,日均约 1,694 次。下载量会把 CI 构建、镜像同步和作为其他包依赖的安装一并计入,适合横向比较热度,不能直接等同于使用人数。

@featbit/openfeature-provider-node-server 还在维护吗?

最新版本 1.4.1 发布于 2026/11/04(10 天前);至今共发布 10 个版本,其中过去 12 个月发布了 6 个;首次发布于 2024/01/09。发布频率只是参考信号:功能稳定的工具可能很少需要更新,建议结合源码仓库的 issue 和提交记录判断。