@configdirector/nuxt-sdk

中文文档
1.14.2发布于 2026/11/08MITTypeScriptES Module构建来源已验证近 30 天下载 3123

Nuxt SDK for ConfigDirector. ConfigDirector is a remote configuration and feature flag service.

原始使用文档
文档目录5 节
  1. Install
  2. Retrieve a value
  3. Test your code
  4. Documentation
  5. Getting Help

ConfigDirector Nuxt SDK

npm

Nuxt SDK for ConfigDirector, remote config and feature flags with typed values, JSON Schema validation, and safe renames of live flags. Start free, no card required.

Install

npm install --save @configdirector/nuxt-sdk

Retrieve a value

// nuxt.config.ts
export default defineNuxtConfig({
  modules: ["@configdirector/nuxt-sdk"],
  runtimeConfig: {
    public: { configdirector: { clientSdkKey: "YOUR-CLIENT-SDK-KEY" } },
    configdirector: { serverSdkKey: "YOUR-SERVER-SDK-KEY" },
  },
});
<script setup lang="ts">
const { value: darkMode } = useConfigDirectorValue("dark-mode", false);
</script>

Full details are in the official documentation.

Test your code

@configdirector/nuxt-sdk/testing creates a real client connected to an in-memory server that your test controls. Install it before the Nuxt app is created, at the top level of a test file or a vitest setup file, and the ConfigDirector plugin provides it to the app instead of building a client. Tests run in the nuxt environment of @nuxt/test-utils 4 (which needs vitest 4).

import { nextTick } from "vue";
import { mountSuspended } from "@nuxt/test-utils/runtime";
import { createTestClient, installTestClient } from "@configdirector/nuxt-sdk/testing";
import Checkout from "~/components/Checkout.vue";

const testClient = createTestClient({ values: { "dark-mode": true } });
installTestClient(testClient);

test("renders the dark mode", async () => {
  const component = await mountSuspended(Checkout);
  expect(component.text()).toContain("dark-mode: true");

  testClient.setValue("dark-mode", false);
  await nextTick();
  expect(component.text()).toContain("dark-mode: false");
});

@nuxt/test-utils 4 creates the app once per test file, inside a beforeAll hook, so install at module level rather than in a hook, and reset the values between tests with replaceValues. @nuxt/test-utils 3 creates the app before the test file loads, so the plugin cannot see a test client installed there; upgrade to use the testing entry. While installed, the plugin needs no clientSdkKey. Await nextTick() after setValue, removeValue, and replaceValues. The test client also holds or fails initialize and updateContext, and records every context in contextUpdates.

Documentation

Refer to the official documentation for the Nuxt SDK.

There is also a quickstart guide for ConfigDirector and any of our SDKs.

Getting Help

版本与发布记录

@configdirector/nuxt-sdk 共发布 36 个版本,首次发布于 2026/04/30;过去 12 个月发布了 36 个版本。最新版本附带 npm provenance 构建来源证明,可追溯到公开的 CI 构建记录。

版本发布日期距今
1.14.2latest2026/11/082 天前
1.14.12026/11/082 天前
1.14.02026/11/064 天前
1.13.22026/11/028 天前
1.13.12026/10/3011 天前
1.13.02026/10/2813 天前

关于 @configdirector/nuxt-sdk 的常见问题

@configdirector/nuxt-sdk 是什么?

Nuxt SDK for ConfigDirector. ConfigDirector is a remote configuration and feature flag service.

如何安装 @configdirector/nuxt-sdk?

在项目目录运行 npm install @configdirector/nuxt-sdk,或使用 pnpm add / yarn add / bun add。

@configdirector/nuxt-sdk 支持 TypeScript 吗?

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

@configdirector/nuxt-sdk 支持 ESM 还是 CommonJS?

以 ES Module 形式发布,推荐使用 import 引入。在 CommonJS 项目中,Node.js 20.19+ / 22.12+ 可以直接 require() 不含顶层 await 的 ES Module,更早的版本需要改用动态 import()。

@configdirector/nuxt-sdk 可以商用吗?

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

@configdirector/nuxt-sdk 的下载量有多少?

根据 npm 官方下载统计,@configdirector/nuxt-sdk 在 2026/10/11 – 2026/11/09 这 30 天内被下载 3,123 次,日均约 104 次。下载量会把 CI 构建、镜像同步和作为其他包依赖的安装一并计入,适合横向比较热度,不能直接等同于使用人数。

@configdirector/nuxt-sdk 还在维护吗?

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