An example Node.js application using Featurevisor through the OpenFeature server SDK.
The application loads a published Featurevisor datafile, registers the Featurevisor OpenFeature provider, and evaluates a boolean flag through an OpenFeature client.
See the required Node.js version in .nvmrc.
npm cinpm startThe provider maps the OpenFeature targetingKey field to Featurevisor's userId context attribute by default. Other context fields are passed to Featurevisor unchanged.
Featurevisor flags, variations, and variables use these OpenFeature keys:
| OpenFeature key | Featurevisor evaluation |
|---|---|
checkout |
Flag |
checkout:variation |
Variation |
checkout:title |
Variable named title |
Use the OpenFeature resolver matching the expected value type. For example:
const enabled = await client.getBooleanValue("checkout", false, context);
const variation = await client.getStringValue(
"checkout:variation",
"fallback",
context,
);
const title = await client.getStringValue(
"checkout:title",
"Default title",
context,
);The test uses an in memory datafile, so it does not depend on a remote service:
npm testIt covers a flag, a variation, string and number variables, context mapping, and the OpenFeature default for a missing flag.
This example lets the provider create and own its Featurevisor instance. Calling OpenFeature.close() closes the provider and releases the Featurevisor instance resources.
The provider can also receive an existing instance through its featurevisor option. In that case, the application retains ownership and must close the instance when it is no longer needed.
See the Featurevisor OpenFeature documentation for provider options, resolution details, tracking, diagnostics, and lifecycle behaviour.
MIT © Fahad Heylaal