npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2026 – Pkg Stats / Ryan Hefner

flagtron

v1.0.9

Published

Flagtron Node.js client

Readme

Flagtron-Client

Flagtron is a lightweight feature flag client that integrates with Flagsmith. It fetches all feature flags on initialization and listens for real-time changes via WebSockets.

Features

  • Fetches initial feature flags from Flagsmith
  • Caches feature flags for quick lookups
  • Listens for real-time flag updates via WebSockets
  • Implements a reconnection strategy for WebSocket failures
  • Provides a simple API to retrieve feature flags

Installation

npm install flagtron

or

yarn add flagtron

Usage

Basic Example

Please view https://github.com/anoapay/flagtron/tree/main/server for instructions on how to setup flagtron server. You will need this for flagtronWebsocketServer.

import { Flagtron } from "flagtron";

const config = {
  flagsmithApi: "https://api.flagsmith.com",
  flagsmithEnvironmentId: "your-environment-id",
  flagtronWebsocketServer: "wss://your-websocket-server",
  dependencies: ["feature-flag-1", "feature-flag-2"],
  reconnectInterval: 5000,
  maxReconnectAttempts: 10,
};

const flagtron = new Flagtron(config);

async function main() {
  await flagtron.initialize();

  const featureFlag = flagtron.getFlag("feature-flag-1");
  console.log("Feature flag status:", featureFlag);
}

main();

Configuration Options

| Option | Type | Default | Description | | ------------------------- | ---------- | -------- | --------------------------------------------------- | | flagsmithApi | string | Required | Flagsmith API endpoint | | flagsmithEnvironmentId | string | Required | Your Flagsmith environment ID | | flagtronWebsocketServer | string | Required | WebSocket server for real-time updates | | dependencies | string[] | [] | List of feature flags to track | | reconnectInterval | number | 5000 | Time in ms before attempting to reconnect WebSocket | | maxReconnectAttempts | number | 10 | Maximum WebSocket reconnection attempts |

API

initialize(): Promise<void>

Initializes the flag cache by fetching flags from Flagsmith and connecting to the WebSocket server.

getFlag(flagName: string): IFlag | undefined

Retrieves the cached value of a feature flag.

Example:

const featureFlag = flagtron.getFlag("feature-flag-1");
if (featureFlag?.enabled) {
  console.log("Feature is enabled");
} else {
  console.log("Feature is disabled");
}

Error Handling

  • If the Flagsmith API is unreachable, initialize() will throw an error.
  • If the WebSocket connection fails, Flagtron will attempt to reconnect up to maxReconnectAttempts.

Logging

Flagtron uses a log() utility to output status messages and errors. You can modify it in utils.ts to use a structured logger like winston.

License

MIT