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

next-micro-flags

v0.1.3

Published

Tiny, framework-aware feature flags for Next.js (App Router).

Readme

next-micro-flags

NPM: https://www.npmjs.com/package/next-micro-flags
GITHUB: https://github.com/mauroserralvodev/next-micro-flags

next-micro-flags is a lightweight feature flag utility designed for Next.js applications using the App Router.

It provides a structured way to evaluate feature flags per request and make the results available consistently across middleware, server components and client components. The library focuses on predictable behavior, minimal configuration and zero external dependencies.

Purpose

Feature flags are commonly required in production Next.js applications to control feature availability, reduce rollout risk and manage experimental or temporary functionality.

Typical use cases include:

  • gradual rollouts of new features
  • restricting features to internal or test users
  • enabling features only in specific environments
  • activating features for a limited time window
  • keeping incomplete functionality deployed but inactive

Many implementations rely on ad-hoc conditionals or environment variables, which tend to become difficult to maintain and are not well suited for client-side rendering.

next-micro-flags addresses this by evaluating all feature flags once per request in middleware, performing basic configuration validation during development, and exposing the evaluated results to both server and client layers in a consistent way.

How it works

Feature flags are defined in a single feature-flags.config.js file.

Each flag supports a combination of the following rules:

  • global enable or disable
  • percentage-based rollout
  • deterministic rollouts (the same user receives the same result)
  • restriction to a list of specific users
  • restriction to specific environments
  • activation within a defined time range

The middleware evaluates all flags for the current request and forwards the resolved values to the application. Components then consume these values as simple booleans.

Example configuration:

export const featureFlagsConfig = {
  newNavbar: {
    enabled: true,
    rollout: 100
  },
  betaDashboard: {
    enabled: true,
    rollout: 20
  },
  paymentsV2: {
    enabled: true,
    rollout: 100,
    onlyUsers: ["user1", "user2"]
  },
  devOnlyBanner: {
    enabled: true,
    rollout: 100,
    onlyInEnv: ["development"]
  },
  blackFridayBanner: {
    enabled: true,
    rollout: 100,
    activeFrom: "2025-11-20T00:00:00Z",
    activeUntil: "2025-11-27T23:59:59Z"
  }
};

In the UI, a flag is checked using a simple hook:

const showNewNavbar = useFeatureFlag("newNavbar");

Rendering logic remains explicit and local to the component.

Behavior and guarantees

Flag evaluation is performed once per request. Rollouts are deterministic when a stable identifier is available. Misconfigured flags produce warnings in development but do not break execution. No runtime network calls are required. No client-side configuration parsing is performed. This keeps behavior predictable and avoids hidden side effects.

Internal flow overview

Middleware evaluates all feature flags for the incoming request. The evaluated flag set is serialized into a request header. The root layout reads the evaluated flags on the server. The exposes them to the client through React context. Client components read flag values using hooks and render accordingly.

License

MIT