Featurevisor

Use cases

Offline feature flag evaluation

Featurevisor evaluates flags and variables locally after you supply a datafile. An unavailable CDN does not stop evaluation of the datafile already held by an SDK instance.

Start with a known configuration

Use a datafile produced by the Featurevisor CLI as a bundled startup configuration. In Node.js, a file packaged with your application can be loaded directly:

import { readFileSync } from 'node:fs'
import { createFeaturevisor } from '@featurevisor/sdk'
const bundledDatafile = JSON.parse(
readFileSync(new URL('./datafile.json', import.meta.url), 'utf8'),
)
const f = createFeaturevisor({ datafile: bundledDatafile })
const enabled = f.isEnabled('checkout', { userId: 'user-123' })
const supportEmail = f.getVariable('supportEmail', { country: 'nl' })

The bundled datafile should contain those definitions. Missing flags evaluate as disabled, while missing variables can return undefined. Choose application defaults where appropriate.

Refresh when the network is available

Fetch outside the evaluation path. A failed fetch should leave the current instance in place:

async function refresh() {
try {
const response = await fetch(DATAFILE_URL)
if (!response.ok) throw new Error('Datafile request failed')
const datafile = await response.json()
f.setDatafile(datafile, true)
} catch (error) {
reportRefreshFailure(error)
}
}

Define DATAFILE_URL and reportRefreshFailure in your application. Publish CLI generated datafiles, and connect SDK diagnostics to your monitoring for invalid datafile reports. Do not recreate the instance with empty configuration after a failed refresh.

The base SDK does not fetch, retry, or persist datafiles automatically. Schedule refreshes using your application's lifecycle, and avoid overlapping requests that could apply an older response after a newer one.

Plan for restarts and stale configuration

An in memory datafile lasts only as long as the process or application instance. A cold start during an outage needs a bundled copy or application managed persistent cache.

Record the active revision with f.getRevision() and monitor refresh failures. A cached configuration can keep a retired flag enabled until a refresh succeeds. For actions that require current authorization, use server checks independently of feature flags.

See the Node.js SDK, browser SDK, and runnable examples for your platform. Pair this with a configuration rollback plan.

Previous
Deprecating features