Skip to main content
The Confidence JavaScript SDK provides ultra-low latency feature flag evaluation for Node.js applications using the Confidence Resolver—a Rust-based resolver that runs as WebAssembly.

Features

  • Local evaluation: Flag rules evaluate on your infrastructure in microseconds
  • OpenFeature compatible: Standard feature flag API through OpenFeature provider
  • Background sync: Flag rules and logging sync with Confidence in the background
  • High reliability: No network dependency at evaluation time

Installation

npm install @spotify-confidence/openfeature-server-provider-local
Requirements: Node.js 18+ with WebAssembly support.

Quickstart

import { OpenFeature } from '@openfeature/server-sdk';
import { createConfidenceServerProvider } from '@spotify-confidence/openfeature-server-provider-local';

// Initialize the Confidence provider
const provider = createConfidenceServerProvider({
  flagClientSecret: process.env.CONFIDENCE_FLAG_CLIENT_SECRET!,
});

// Register with OpenFeature
await OpenFeature.setProviderAndWait(provider);
const client = OpenFeature.getClient();

// Evaluate a flag with context
const context = {
  targetingKey: 'user-123',
  country: 'US',
  plan: 'premium',
};

const value = await client.getBooleanValue('my-feature-flag.enabled', false, context);
console.log('Flag value:', value);

Resources