Meta-framework SDKs

Nuxt SDK

Install the Nuxt module and evaluate configs and feature flags in the browser, in server handlers, and during SSR

Introduction

The Nuxt SDK combines a client and a server SDK to provide configs to the browser, to server resource handlers, and to SSR. It is intended to be used by Nuxt web applications running on modern web browsers. All modern web browsers on popular platforms should be supported.

The minimum supported version of Nuxt is 3.7.0.

Browser SDKs are tested on the latest versions of Chrome, Firefox, Safari, and Edge.

Telemetry collection within the browser uses Web Workers to aggregate and send telemetry data. If the SDK runs on older browsers without Web Workers support, config evaluation will continue to work but no telemetry data will be collected for that session.

Installation

The SDK can be installed from NPM: https://www.npmjs.com/package/@configdirector/nuxt-sdk

npm install --save @configdirector/nuxt-sdk

Configure the Nuxt module

The Nuxt SDK requires the client SDK key for evaluation in the browser, and the server SDK key for server side rendering (SSR) and for server routes. Neither key is needed when the application runs without a connection.

You can provide the keys in nuxt.config.ts:

nuxt.config.ts
export default defineNuxtConfig({
  //...
  modules: ["@configdirector/nuxt-sdk"],
  runtimeConfig: {
    public: {
      configdirector: {
        // You can also provide the key at runtime to match the given environment
        // via the NUXT_PUBLIC_CONFIGDIRECTOR_CLIENT_SDK_KEY environment variable
        clientSdkKey: "YOUR-CLIENT-SDK-KEY",
      },
    },
    configdirector: {
      // IMPORTANT: This is a secret, do not commit to your source repository
      // You can provide the server key at runtime via the
      // NUXT_CONFIGDIRECTOR_SERVER_SDK_KEY environment variable
      serverSdkKey: "YOUR-SERVER-SDK-KEY",
    },
  },
});

Since the server SDK key is a secret value, the recommended approach is to provide it via an environment variable:

export NUXT_CONFIGDIRECTOR_SERVER_SDK_KEY=YOUR-SERVER-SDK-KEY

The client key can also be provided via an environment variable, which overrides the key provided in: nuxt.config.ts:

export NUXT_PUBLIC_CONFIGDIRECTOR_CLIENT_SDK_KEY=YOUR-CLIENT-SDK-KEY

Additional configuration options

appName and appVersion

These options allow you to provide your application's name and version. These values can be used in targeting rules conditionals, both in the browser and on the server, during SSR and in server routes. For example, if a certain feature should only be enabled starting with a certain version of your application.

nuxt.config.ts
export default defineNuxtConfig({
  //...
  modules: ["@configdirector/nuxt-sdk"],
  runtimeConfig: {
    public: {
      configdirector: {
        appName: "YOUR-APP-NAME",
        appVersion: "1.0.2",
      },
    },
  },
});

logLevel

The SDK uses the consola logger provided via Nuxt. You can adjust the ConfigDirector's SDK logging level independently for both the client and server side:

nuxt.config.ts
export default defineNuxtConfig({
  //...
  modules: ["@configdirector/nuxt-sdk"],
  runtimeConfig: {
    public: {
      configdirector: {
        /**
         * Log level for the client/browser side of the ConfigDirector Nuxt SDK,
         * using consola's numeric levels.
         * 0 = error, 1 = warn, 2 = log, 3 = info, 4 = debug, 5 = trace.
         */
        logLevel: 4, // debug
      },
    },
    configdirector: {
      /**
       * Log level for the server side of the ConfigDirector Nuxt SDK,
       * using consola's numeric levels.
       * 0 = error, 1 = warn, 2 = log, 3 = info, 4 = debug, 5 = trace.
       */
      logLevel: 3, // info
    },
  },
});

baseUrl

The base URL used to connect to ConfigDirector services. It can be configure independently for the client and server side. This should only be provided if your environment requires you to configure a proxy server in order to connect to ConfigDirector services.

connection

Connection options for the server-side client used during SSR and in server routes. These mirror the connection options of the Node.js SDK and accept the following optional values, plus file and values for offline mode (see Run without a connection):

  • mode
    • The connection mode, which can be streaming, polling or offline. It is recommended to use the default of streaming unless you have a specific need to use polling instead. In offline mode the server never connects to ConfigDirector and serves the values of a file or of connection.values; see Run without a connection.
    • Defaults to streaming
  • pollingInterval
    • The interval, in seconds, between requests for config updates when mode is polling. It has no effect in streaming mode. A value below the minimum of 60 seconds is raised to 60 seconds and a warning is logged. See Polling intervals.
    • Defaults to 300 seconds (5 minutes)
  • timeout
    • How long, in milliseconds, the server-side client waits for its initial config payload from ConfigDirector services during initialization. Until the payload is received, configs evaluate to their default values. This timeout also bounds how long incoming requests are held while the client initializes (see waitForInitialization below).
    • Defaults to 3000 milliseconds
nuxt.config.ts
export default defineNuxtConfig({
  //...
  modules: ["@configdirector/nuxt-sdk"],
  runtimeConfig: {
    configdirector: {
      connection: {
        mode: "streaming",
        timeout: 5_000, // 5,000 milliseconds initialization timeout
      },
    },
  },
});

Each option can also be provided at runtime via environment variables: NUXT_CONFIGDIRECTOR_CONNECTION_MODE, NUXT_CONFIGDIRECTOR_CONNECTION_POLLING_INTERVAL, NUXT_CONFIGDIRECTOR_CONNECTION_FILE, and NUXT_CONFIGDIRECTOR_CONNECTION_TIMEOUT.

The client-side (browser) client accepts the same options under runtimeConfig.public.configdirector.connection, plus values for offline mode, with the client SDK defaults: mode defaults to streaming unless the server runs in offline mode, which the browser then follows, pollingInterval defaults to 60 seconds with a minimum of 30 seconds, and timeout defaults to 2000 milliseconds. See Polling intervals. The browser client keeps the last values it received on the device by default and serves them on the next page load of the same context until live values arrive, as the JavaScript SDK does.

nuxt.config.ts
export default defineNuxtConfig({
  //...
  modules: ["@configdirector/nuxt-sdk"],
  runtimeConfig: {
    public: {
      configdirector: {
        connection: {
          mode: "polling",
          pollingInterval: 120, // seconds
        },
      },
    },
  },
});

The client-side options can also be provided at runtime via environment variables: NUXT_PUBLIC_CONFIGDIRECTOR_CONNECTION_MODE, NUXT_PUBLIC_CONFIGDIRECTOR_CONNECTION_POLLING_INTERVAL, and NUXT_PUBLIC_CONFIGDIRECTOR_CONNECTION_TIMEOUT.

Run without a connection

Set the server-side connection mode to offline to run your application without connecting to ConfigDirector, for example in a matrix of UI tests where each cell pins every flag to a known value. Neither the server nor the browser needs an SDK key, no connection is opened and nothing is sent, so the application is invisible to the ConfigDirector dashboard: no evaluations are counted and no lifecycle state changes. Every context receives the same value and targeting rules are not applied.

Give the values once, to the server side, in a JSON file with one value per config key. The mode and the file can both be set through environment variables, so one build runs every cell with no code change:

flags/new-checkout-on.json
{
  "new-checkout": true,
  "max-items": 20,
  "greeting": "hello",
  "theme": { "color": "blue" }
}
NUXT_CONFIGDIRECTOR_CONNECTION_MODE=offline NUXT_CONFIGDIRECTOR_CONNECTION_FILE=./flags/new-checkout-on.json node .output/server/index.mjs

The file path is resolved against the working directory of the server process. The values can also be given inline in nuxt.config.ts as connection.values instead of a file:

nuxt.config.ts
export default defineNuxtConfig({
  //...
  modules: ["@configdirector/nuxt-sdk"],
  runtimeConfig: {
    configdirector: {
      connection: {
        mode: "offline",
        values: { "new-checkout": true, "max-items": 20 },
      },
    },
  },
});

The config type of each value follows from the value itself: a boolean, an integral number (integer), any other number (float), a string, or an object or array (json). A value read with an in-code default value of another type returns the in-code default value, as it does against ConfigDirector.

The browser follows the server. When the server runs in offline mode and runtimeConfig.public.configdirector.connection sets neither mode nor values, the browser fetches the server's values once from /_configdirector/offline-values, a route the module serves only in offline mode, and serves them in offline mode too, so SSR, hydration and the browser show the same values and clientSdkKey can be left out. useConfigDirectorStatus reports loading until the values arrive and ready right after, as it does while a live connection opens. Give the public connection its own mode and values to override this; the browser then serves those, whatever mode the server runs in, and the server serves its own, with no check that the two agree. In the same way, a browser given mode: "streaming" and a clientSdkKey connects to ConfigDirector as usual while the server runs in offline mode.

With mode: "offline" and neither file nor values, the server is ready at once and every config returns its in-code default value on both sides.

When the values cannot be loaded, every request fails with a ConfigDirectorInitializationError instead of rendering in-code default values, whatever waitForInitialization says: the file is missing, cannot be read, is not a JSON object or holds a value such as null; file and values are both given; or either is given in streaming or polling mode. A test cell with a misspelled path fails instead of passing on in-code default values. pollingInterval, timeout and baseUrl have no effect in offline mode.

A statically generated site (nuxt generate) has no server at runtime, so there is no route to fetch the values from. Give the browser its own values with runtimeConfig.public.configdirector.connection: { mode: "offline", values } in nuxt.config.ts.

If you come from LaunchDarkly, a file of values is what LaunchDarkly calls "flags from files", and offline with no values is its "offline mode".

waitForInitialization

When your Nuxt server starts, the server-side client connects to ConfigDirector and waits for its initial config payload. Any request that arrives before that payload is received (typically only the first few requests after a server start or a deploy) is held until the payload arrives, so SSR and server routes evaluate real config values instead of defaults. This behavior is enabled by default.

The wait is bounded by the connection timeout. If the timeout expires before the payload is received:

  • The held requests are released and handled with default config values, and the client logs a warning.
  • Requests that arrive afterwards are no longer held. They also evaluate to default values until the payload arrives.
  • In streaming mode, the client keeps trying to connect in the background and starts serving real values as soon as the payload is received. In polling mode, the next attempt happens on the following polling interval.

Requests are never held once initialization has settled, whether it succeeded, timed out, or failed with an unrecoverable error such as an invalid server SDK key. In normal operation, the payload arrives well within the timeout and the hold is barely noticeable.

Holding requests during startup avoids rendering pages with default values that are then replaced by the real values once the browser client connects, which shows up as a visible flash of content and, in some cases, a hydration mismatch.

If you prefer requests to be handled immediately during startup, accepting that they will evaluate configs to their default values until the payload arrives, you can opt out:

nuxt.config.ts
export default defineNuxtConfig({
  //...
  modules: ["@configdirector/nuxt-sdk"],
  runtimeConfig: {
    configdirector: {
      waitForInitialization: false,
    },
  },
});

The option can also be set at runtime via the NUXT_CONFIGDIRECTOR_WAIT_FOR_INITIALIZATION environment variable. It has no effect in offline mode, where requests always wait for the values to load, which happens at once, and fail when they cannot be loaded (see Run without a connection).

deferInitialization

By default, the browser client connects to ConfigDirector as soon as the app is created, with whatever context it has at that point. An app that knows its context only after startup, such as one with ssr: false or one that fetches the signed-in user in the browser, therefore opens a first connection with no context and a second one once it calls updateContext. The visitor of that first connection counts as a monthly active user in addition to the signed-in user, and the values kept on the device for the signed-in user are not served until the second connection opens.

Turn on deferInitialization to make the browser client wait for its first context instead:

nuxt.config.ts
export default defineNuxtConfig({
  //...
  modules: ["@configdirector/nuxt-sdk"],
  runtimeConfig: {
    public: {
      configdirector: {
        deferInitialization: true,
      },
    },
  },
});

With the option on, nothing connects and nothing is sent until the app calls updateContext from useConfigDirectorContext. Until then, useConfigDirectorStatus reports loading and configs return their in-code default values. The first updateContext call starts the client with that context: one connection opens and carries it, the values kept on the device for that context are served until live values arrive, and the status becomes ready, or default when the connection timeout passes without values, as at startup without the option. Later calls update the context as usual.

A context set during server-side rendering is already known when the app is created in the browser, so the client starts with it right away, as it does without the option. A page that never sets a context never connects and stays loading; with SSR on, such a page renders the server's values and then shows the in-code default values once hydrated. So turn the option on only when every page that reads configs sets a context. The option has no effect in offline mode, where the client is ready at once with its values.

The option can also be set at runtime via the NUXT_PUBLIC_CONFIGDIRECTOR_DEFER_INITIALIZATION environment variable.

Hooks

Hooks are events you can subscribe to in order to be notified of some key actions from the client instances. Since the Nuxt SDK utilizes both client (browser) and server instances, there are two separate composables to register hook handlers.

You can learn more about client side hooks in the Hooks section of the Browser Javascript SDK.

You can learn more about server side hooks in the Hooks section of the Node.js SDK.

Client-side Hooks

The useConfigDirectorClientHooks composable can be used to register client-side hook handlers. There are two recommended ways of using the composable:

  1. Registering in a Nuxt plugin (recommended for clientReady and configsUpdated):

The browser client initializes during Nuxt's app:created lifecycle hook, before any page components mount. Registering clientReady and configsUpdated handlers in a Nuxt plugin ensures they're in place before initialization is completed and the events are fired for the first time:

plugins/configdirector-hooks.client.ts
export default defineNuxtPlugin(() => {
  useConfigDirectorClientHooks({
    clientReady: ({ action }) => {
      console.log(`ConfigDirector client ready (${action})`);      
    },
    configsUpdated: ({ keys }) => {
      console.log("Configs updated:", keys);
    },
  });
});

The .client.ts suffix ensures this plugin runs only in the browser, not during SSR.

This approach of registering hook handlers in a plugin, is also suitable for contextUpdated and configEvaluated in cases where the handlers are for global behavior (as opposed of page or component specific).

  1. Registering in a page component:

For hooks handlers for page or component specific behavior, register them inside a component's <script setup>. The composable automatically removes the handlers when the component unmounts, so they won't accumulate across navigation.

pages/profile.vue
<script setup lang="ts">
const { updateContext } = useConfigDirectorContext();

useConfigDirectorClientHooks({
  contextUpdated: ({ context }) => {
    console.log("Context changed:", context);    
  },
  configEvaluated: ({ evaluation }) => {
    console.log("Config evaluated": evaluation);
  },
});
</script>

Server-side Hooks

The useConfigDirectorServerHooks composable can be used to register server-side hook handlers. Server hooks run against the long-lived Nitro singleton ConfigDirector client instance. Register them in a Nitro plugin in server/plugins/ which runs once at server startup:

server/plugins/configdirector-hooks.ts
export default defineNitroPlugin(() => {
  useConfigDirectorServerHooks({
    clientReady: () => {
      console.log("Server SDK connected to ConfigDirector");
    },
    configsUpdated: ({ keys }) => {
      console.log("Server-side configs updated:", keys);
    },
    configEvaluated: ({ evaluation }) => {
      console.log("Config evaluated": evaluation);
    },
  });
});

Retrieve config values

The useConfigDirectorValue composable is available to app components. On the server side, the useConfigDirectorServerClient composable returns the global server instance of the client (an instance of the Node.js SDK).

Retrieving config values in components:

YourComponent.vue
<script setup lang="ts">
const { value } = useConfigDirectorValue("my-config-key", false);
</script>

<template>
  <div>my-config-key is : {{ value }}</div>
</template>

Retrieving config values in server resource handlers:

server-resource.get.ts
export default defineEventHandler(async (_event) => {
  const client = useConfigDirectorServerClient();
  return client.getValue("my-config-key", false);
});

The value returned by the useConfigDirectorValue composable is a ShallowRef that will update whenever the config value is updated in the ConfigDirector dashboard, or if it evaluates to a different value due to targeting rules (for example, if the context is updated). Keep in mind that it is a ShallowRef when accessing it in scripts:

YourComponent.vue
<script setup lang="ts">
const { value: myConfigValue } = useConfigDirectorValue("my-config", "default value");

const someOtherDerivedValue = computed(() => `Hello ${myConfigValue.value}`);
</script>

<template>
  <div>my-config is : {{ someOtherDerivedValue }}</div>
</template>

You can also determine if the client is still initializing, so rather than transition from the default value to the evaluated value, you can show a loading state until the client is ready and config values are evaluated:

YourComponent.vue
<script setup lang="ts">
const { value, loading } = useConfigDirectorValue("my-config", "default value");
</script>

<template>
  <div v-if="loading">Loading...</div>
  <div v-else>my-config is : {{ value }}</div>
</template>

Additionally, you can also use the useConfigDirectorStatus composable to retrieve just the status:

YourComponent.vue
<script setup lang="ts">
const { loading } = useConfigDirectorStatus();
</script>

<template>
  <div v-if="loading">Loading...</div>
  <div v-else><SomeComponentThatUsesConfigValues /></div>
</template>

SSR config evaluation

Evaluation of config values during server side rendering (SSR) utilizes the global server instance of the ConfigDirector Node.js client. That means there are no additional network requests that take place since the server SDK evaluates targeting rules locally for any given context.

For SSR to work correctly, configs need to be made available to both, the client and the server, in the ConfigDirector dashboard.

On the server, a context without an id skips percentage rollouts: the targeting rules after the rollout are tried, and the default targeting rule value is served when none of them applies, as described for the Node.js SDK. In the browser, such a visitor stays in a rollout through the instance ID the SDK keeps. When a visitor who has not signed in should get the same rollout value from server rendering and in the browser, give the context the same id on both sides, such as a session ID from a cookie. Versions 1.14.0 and 1.14.1 of the SDK ended the evaluation at the skipped rollout on the server, and versions before 1.14.0 served every context without an id the first share of the rollout.

Update the context

The context can be updated via the useConfigDirectorContext composable:

YourComponent.vue
<script setup lang="ts">
const { updateContext } = useConfigDirectorContext();
const { value } = useConfigDirectorValue("my-config-key", false);

const onUpdate = () => {
  updateContext({
    id: "654321",
    name: "Another User",
    traits: {
      region: "Australia",
    },
  });
};
</script>

<template>
  <div>my-config-key is : {{ value }}</div>
  <button type="button" @click="onUpdate">Update Context</button>
</template>

On server resource handlers, the context is provided at evaluation time as the third argument to getValue. Unlike client SDKs, the server SDKs are able to evaluate targeting rules for the given context locally without additional network calls.

server-resource.get.ts
export default defineEventHandler(async (_event) => {
  const client = useConfigDirectorServerClient();
  return client.getValue("my-config-key", false, {
    id: "654321",
    name: "Another User",
    traits: {
      region: "Australia",
    },
  });
});

To evaluate configs for an entity other than a user, such as a tenant, set the context kind with kind. It works the same in updateContext and in getValue:

server-resource.get.ts
return client.getValue("my-config-key", false, {
  id: "acme",
  kind: "tenant",
  name: "Acme Inc.",
  traits: {
    plan: "enterprise",
  },
});

Leaving kind out means user. A context kind is 1 to 64 lowercase letters, digits, dashes, or underscores. A context with an invalid context kind is ignored: the SDK logs an error, and configs are evaluated as if no context had been given. Context kinds are available from version 1.10.0 of the SDK.

Updating the context on the client side re-establishes a new connection to ConfigDirector servers with the new context. While the new connection is in flight, config values will continue to evaluate to the currently cached values from the prior context.

If your app learns its context only after startup, for example with ssr: false or once it has fetched the signed-in user, turn on deferInitialization so that the browser client waits for the first updateContext call and its first connection already carries the context.

In the browser, the SDK keeps an instance ID in localStorage until the site's data is cleared, and ConfigDirector derives the identifier of a context without an id from it. A visitor who has not signed in keeps that identifier, and their percentage rollout bucket, from one visit to the next, and counts as one monthly active user however often they visit.

useConfigDirectorClient composable

In the event that you need to have access to the underlying Javascript ConfigDirectorClient instance in app components for more complex behaviors, you can access the instance via the useConfigDirectorClient composable:

YourComponent.vue
<script setup lang="ts">
const { client } = useConfigDirectorClient();

// Utilize the client for more involved logic
</script>

<template>
  <div>A component with more complex usage</div>
</template>
Proceed with caution when using the useConfigDirectorClient composable. The useConfigDirectorValue and useConfigDirectorContext composables manage listeners and cleanup automatically. However, if you make use of the useConfigDirectorClient composable, you must manage cleaning up any listeners yourself.
Additionally, any calls to dispose, unwatch, or unwatchAll on the client instance can have unintended side effects and may result in subtle bugs.

evaluate

Both clients can return the evaluation behind a value instead of the value alone: the value, whether it is the in-code default value, the reason, the valueId, and the variation. In app components, the client from useConfigDirectorClient has evaluate(key, defaultValue), as described for the JavaScript SDK. During server rendering it reads through the server client, so there it can report the reason rollout-skipped-no-identifier for a context without an id. In server code, the client from useConfigDirectorServerClient has evaluate(key, defaultValue, context), with the context optional as in getValue, as described for the Node.js SDK. Use it where the reason matters at the point of the read, such as when reporting an evaluation to another system. @configdirector/nuxt-sdk exports the ConfigEvaluation, EvaluationReason and Variation types. evaluate is available from version 1.13.0 of the SDK, and its variation from version 1.14.0.

server-resource.get.ts
export default defineEventHandler(async (_event) => {
  const evaluation = useConfigDirectorServerClient().evaluate("new-checkout", false, { id: "user-id" });
  return { newCheckout: evaluation.value, reason: evaluation.reason };
});

track

Both clients report to ConfigDirector that something happened, such as a completed checkout, so ConfigDirector can show it on the Live feed and count it for each variation of a running experiment. In app components, the client from useConfigDirectorClient has track(eventName, options), which reports the event for the current context, as described for the JavaScript SDK. During server rendering it reports the event for the context of the request being rendered. In server code, the client from useConfigDirectorServerClient has track(eventName, context, options), with the context and the options optional, as described for the Node.js SDK. An event counts for an experiment only when it carries the id of the context the experiment's config was evaluated for, so in server code pass the context you evaluate with. track is available from version 1.14.0 of the SDK.

checkout.post.ts
export default defineEventHandler(async (event) => {
  const order = await completeCheckout(event);
  useConfigDirectorServerClient().track("checkout-completed", { id: order.userId }, { value: order.total });
  return { orderId: order.id };
});

Test your components

Use the SDK's testing entry point, @configdirector/nuxt-sdk/testing, to test components and composables that read your configs and flags. It creates a test client: the SDK's real client connected to an in-memory server that your test controls. Only the connection to ConfigDirector is replaced. Everything else is the same code that runs in production, including the plugin and the composables, so your components behave exactly as they do against ConfigDirector, and no network connection is opened and no telemetry is sent.

Tests run in the nuxt environment of @nuxt/test-utils version 4, which creates your Nuxt app inside the test process. installTestClient makes the ConfigDirector plugin provide the test client's client to the app instead of building one:

Checkout.nuxt.spec.ts
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: { "new-checkout": true } });
installTestClient(testClient);

beforeEach(() => testClient.replaceValues({ "new-checkout": true }));

test("shows the new checkout when the flag is on", async () => {
  const component = await mountSuspended(Checkout);
  expect(component.text()).toContain("New checkout");

  testClient.setValue("new-checkout", false);
  await nextTick();
  expect(component.text()).toContain("Classic checkout");
});

@nuxt/test-utils 4 creates the app once per test file, in a beforeAll hook that runs before your own hooks, so call installTestClient at the top level of the test file, or of a vitest setupFiles entry, and not inside beforeAll or beforeEach. @nuxt/test-utils 3 creates the app before your test file loads, so the plugin cannot see a client installed there: the testing entry needs version 4, which in turn needs vitest 4. Because the app and its client live for the whole file, reset the values between tests with replaceValues. Await nextTick() after setValue, removeValue, and replaceValues, since they update the composables' refs synchronously and Vue renders on the next tick.

What the plugin does with an installed client

  • It provides the installed client to the app and does not build one, so the app under test needs no clientSdkKey. Of the public configdirector runtime config, only logLevel and deferInitialization apply.
  • It does not call initialize on a client that is ready or initializing. If the client is ready and the app's context differs from the client's, it calls updateContext instead. The status from useConfigDirectorStatus starts as ready for a ready client.
  • With deferInitialization on, it waits for the app's first context as in production: a client that is neither ready nor initializing is left untouched while the app has no context, and the first updateContext call starts it with that context.
  • It keeps its clientReady handler registered for the app's lifetime, as in production, and never disposes the client.

Server code is not covered: the nuxt environment does not run Nitro, so the server plugin, the server useConfigDirectorServerClient composable, and your server handlers run only in end-to-end tests. Those start the built app in a separate process, where the SDK connects to the baseUrl from the runtime config as it does in production.

Test client controls

values, setValue, removeValue, and replaceValues take native values, and the config type follows from each value: a boolean, an integral number (integer), any other number (float), a string, or a plain object or array (json). holdInitialization, completeInitialization, and failInitialization drive initialize, so the loading and default statuses can be tested, and holdContextUpdate, completeContextUpdate, and failContextUpdate do the same for updateContext. contextUpdates records the context of every initialize and updateContext call, and trackedEvents the events the code under test tracked with track. The JavaScript SDK's testing section describes every control and what to expect from the client.