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

@sanely/flags

v0.1.0

Published

Type-safe feature flag library for TypeScript applications

Readme

@sanely/flags adds a type-safe evaluation layer to your feature flag service. You declare each flag once, write or install a provider, and read flags through a reader. The package manages identity resolution, validation, fallback values, hooks, caching, request coalescing, batches, timeouts, and server snapshots.

The package works in browsers and servers. React support is an optional entry point.

Features

  • Flags as code. Each flag is a value with its key and default, so your editor can find every read.
  • Type-safe flags. TypeScript infers boolean values, string variants, and payload types.
  • Any provider. Write a provider with defineProvider, and switch providers without a change to read sites.
  • Safe fallback. A failed evaluation returns the default, and its details carry a tagged error.
  • Efficient evaluation. Store decisions, coalesce requests, or read several flags in one request.
  • Server rendering. Render with a server snapshot and hydrate with no mismatch.
  • React support. Use flags with React 19 and Suspense.
  • Test helpers. Set flag values in tests with a fake provider.
  • No external dependencies. The only runtime dependency is @sanely/duration, which reads time expressions such as "500ms". Install React only when your application needs it.

Install

npm install @sanely/flags

The package needs Node.js 22 or later on the server. The React entry point needs React 19.2 or later.

Get started

  1. Declare your flags in a module that imports only @sanely/flags:

    // flags/definitions.ts
    import { flag } from "@sanely/flags"
    
    export const betaAccess = flag.boolean("beta-access", false)
    export const theme = flag.variant("theme", ["light", "dark", "system"], "light")
  2. Write a provider for your feature flag service:

    import { decision, defineProvider, type Identity } from "@sanely/flags"
    
    export const provider = defineProvider({
      name: "my-service",
      decideOne: async (flag, identity: Identity) => {
        const result = await service.evaluate(flag.key, identity.distinctId)
        return flag.kind === "boolean"
          ? decision.boolean(result.enabled)
          : decision.variant(result.variant)
      },
    })
  3. Create a reader, and read your flags:

    import { createFlags } from "@sanely/flags"
    
    const flags = createFlags({ provider, identify: () => ({ distinctId: getCurrentUserId() }) })
    
    if (await flags.get(betaAccess)) {
      showBetaFeatures()
    }
    
    const [hasBeta, selectedTheme] = await flags.getMany([betaAccess, theme])

flags.get(betaAccess) returns false when identity resolution or the provider fails, so your application continues with a known value.

Documentation

How-to guides:

Reference:

Explanation:

Contributing

Read the contributor guide before changing the package. To report a vulnerability, read SECURITY.md.

License

MIT. See LICENSE.