🚨 Latest Research:Tanstack npm Packages Compromised in Ongoing Mini Shai-Hulud Supply-Chain Attack.Learn More
Socket
Book a DemoSign in
Socket

@openflagsdev/js

Package Overview
Dependencies
Maintainers
1
Versions
2
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@openflagsdev/js

JavaScript/TypeScript SDK for OpenFlags — feature flags with local evaluation.

latest
Source
npmnpm
Version
0.1.1
Version published
Maintainers
1
Created
Source

@openflagsdev/js

JavaScript/TypeScript SDK for OpenFlags. Fetches flags from the server and evaluates them locally (enabled, rollout percentage, user list).

Install

In the monorepo: dependency on @openflagsdev/types. From outside, install @openflagsdev/js (when published).

Usage

import { createClient } from "@openflagsdev/js"

const client = await createClient({
  apiUrl: "https://flags.example.com",
  project: "my-app", // project slug or id from the dashboard
  userId: "user-123", // optional; call client.identify(userId) when the user logs in or changes
})

if (client.isEnabled("new_checkout")) {
  // show new checkout
}

const all = client.getAll() // { "new_checkout": true, "beta_ui": false }

// When the user logs in or changes (e.g. logout → identify(null))
client.identify("user-456")
client.identify(null) // clear user (anonymous)

API

  • createClient(config) — Fetches flags from GET {apiUrl}/projects/:project/flags. Returns a client with:
    • isEnabled(flagKey)true if the flag is on for this user (respects rollout % and explicit user list).
    • getAll()Record<flagKey, boolean> for all flags.
    • identify(userId) — Set or update the current user. Pass null to clear (e.g. logout). Evaluation uses the new user on the next call.

Config: apiUrl, project (slug or id from the dashboard), userId (optional).

Scripts

  • bun run build — Compile TypeScript to dist/
  • bun test — Run tests

Types

Flag shapes and evaluation rules come from @openflagsdev/types.

Keywords

feature-flags

FAQs

Package last updated on 09 Mar 2026

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts