> ## Documentation Index
> Fetch the complete documentation index at: https://confidence.spotify.com/llms.txt
> Use this file to discover all available pages before exploring further.

# JavaScript (Node.js)

> Confidence JavaScript SDK for server-side feature flag evaluation in Node.js.

The Confidence JavaScript SDK provides ultra-low latency feature flag evaluation for Node.js applications using the [Confidence Resolver](https://github.com/spotify/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

<CodeGroup>
  ```bash npm theme={null}
  npm install @spotify-confidence/openfeature-server-provider-local
  ```

  ```bash yarn theme={null}
  yarn add @spotify-confidence/openfeature-server-provider-local
  ```

  ```bash pnpm theme={null}
  pnpm add @spotify-confidence/openfeature-server-provider-local
  ```
</CodeGroup>

**Requirements**: Node.js 18+ with WebAssembly support.

## Quickstart

```typescript theme={null}
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

<CardGroup cols={2}>
  <Card title="GitHub repository" icon="github" href="https://github.com/spotify/confidence-resolver/tree/main/openfeature-provider/js">
    Source code and examples
  </Card>

  <Card title="OpenFeature JS SDK" icon="flag" href="https://openfeature.dev/docs/reference/technologies/server/javascript">
    OpenFeature documentation
  </Card>

  <Card title="Context" icon="sliders" href="/docs/sdks/context">
    Configure evaluation context
  </Card>

  <Card title="Apply events" icon="chart-line" href="/docs/sdks/apply-event">
    Understand flag assignment tracking
  </Card>
</CardGroup>
