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

@myflags/core

v0.3.0

Published

Core SDK for MyFlags feature flag management

Downloads

38

Readme

@myflags/core

Website

MyFlags - The modern way to manage feature flags in your applications. Ship features faster, control releases with confidence, and deliver better user experiences.

The core package of MyFlags SDK, providing the fundamental functionality for feature flag management.

Installation

npm install @myflags/core
# or
yarn add @myflags/core
# or
pnpm add @myflags/core

Usage

Basic Setup

import { MyFlagsSDK } from "@myflags/core";

// Initialize the SDK with your configuration
const sdk = new MyFlagsSDK({
  apiKey: "your-api-key",
  projectId: "your-project-id",
  environment: "production", // optional, defaults to 'production'
  refreshInterval: 600000, // optional, defaults to 10 minutes
  retryCount: 3, // optional, defaults to 3 retries for failed API requests
  retryDelay: 1000, // optional, defaults to 1000ms between retries
});

Checking Feature Flags

// Get all feature flags
const flags = await sdk.getFlags();

// Check if a specific feature is enabled
const isEnabled = await sdk.getFlag("feature_key");

Configuration Options

interface MyFlagsConfig {
  apiKey: string; // Required: Your MyFlags API key
  projectId: string; // Required: Your MyFlags Project key
  environment?: "production" | "development" | "testing"; // Optional: Environment
  refreshInterval?: number; // Optional: Refresh interval in milliseconds
  retryCount?: number; // Optional: Number of retries for failed API requests
  retryDelay?: number; // Optional: Delay between retries in milliseconds
}

API Reference

MyFlagsSDK

The main class for interacting with the MyFlags service.

Constructor Options

| Option | Type | Default | Description | | --------------- | ------------------------------------------ | ------------ | ----------------------------------------- | | apiKey | string | - | Your MyFlags API key | | projectId | string | - | Your project ID | | environment | 'production' | 'development' | 'testing' | 'production' | Environment to use | | refreshInterval | number | 600000 | Interval in milliseconds to refresh flags | | retryCount | number | 3 | Number of retries for failed API requests | | retryDelay | number | 1000 | Delay between retries in milliseconds |

Methods

  • getFlags<T extends Flag>(): Promise<T> - Get all feature flags
  • getFlag(key: string): Promise<boolean> - Check if a specific feature is enabled
  • subscribe(callback: (flags: Flag) => void): Promise<() => void> - Subscribe to flag updates. The callback will be called immediately and then at the specified refresh interval. Returns an unsubscribe function to clean up the subscription.

Real-time Updates

You can subscribe to flag updates to get real-time notifications when flags change:

const sdk = new MyFlagsSDK({
  apiKey: "your-api-key",
  projectId: "your-project-id",
  refreshInterval: 5000, // Check for updates every 5 seconds
});

// Subscribe to flag updates
const unsubscribe = await sdk.subscribe((flags) => {
  console.log("Flags updated:", flags);
});

// Later, when you want to stop receiving updates
unsubscribe();

Best Practices

  1. Initialization

    • Initialize the SDK early in your application lifecycle
    • Store your API key securely
    • Use appropriate environment settings
  2. Error Handling

    • The SDK handles errors gracefully by returning empty objects or false values
    • Implement appropriate fallback values in your application
    • Monitor API responses for potential issues
  3. Performance

    • Use appropriate refresh intervals based on your needs
    • Consider implementing caching for frequently accessed flags
    • Monitor memory usage with large flag sets
  4. Security

    • Never expose your API key in client-side code
    • Use environment variables for sensitive configuration
    • Implement proper access control for flag management

Contributing

See the Contributing Guide for details on how to contribute to this package.

License

This package is licensed under the MIT License - see the LICENSE file for details.