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

flagkit

v0.0.5

Published

Add feature flags to your Nuxt app

Readme

FlagKit Banner

FlagKit

npm version npm downloads license

A powerful and flexible feature flags module for Nuxt 3 with TypeScript support, auto-imports, and rule-based evaluation.

⚠️ Early Development Stage! ⚠️

FlagKit is a new project and currently in its early stages of development. While I'm working to make it stable and feature-rich, please be aware that APIs might change, and you might encounter some rough edges.

Your contributions, feedback, and even forks to experiment are highly welcome and appreciated! Let's build something great together.

✨ Features

  • 🚀 Simple API - Easy to use composables with excellent DX
  • 🔧 Multiple Activation Methods - Static config, environment variables, and dynamic rules
  • 📝 TypeScript Support - Full type safety with autocompletion for flag names
  • 🎯 Flexible Rules - Path-based evaluation system for any context (user, team, subscription, etc.)
  • 🔄 Reactive - Automatically updates when context changes
  • 🌐 SSR/SSG Compatible - Works seamlessly with server-side rendering
  • 🐛 Debug Mode - Detailed logging for development
  • 🔌 Auto-imports - No manual imports needed

📦 Installation

You can auto-install the module with the following command:

npx nuxi module add flagkit

Or manually install it with your package manager of choice:

npm install flagkit
# or
pnpm add flagkit
# or
yarn add flagkit

Then add the module to your nuxt.config.ts:

export default defineNuxtConfig({
  modules: ['flagkit'],
})

🚀 Quick Start

  1. Configure the module in your nuxt.config.ts:
export default defineNuxtConfig({
  modules: ['flagkit'],
  
  flagkit: {
    debug: true, // Enable debug mode in development
    flags: {
      'new-dashboard': {
        enabled: true,
        description: 'Enable the new dashboard design'
      },
      'admin-panel': {
        enabled: false,
        description: 'Admin panel access',
        rules: [
          {
            path: 'user.role',
            operator: 'equals',
            value: 'admin'
          }
        ]
      }
    }
  }
})
  1. Use in your components:
<template>
  <div>
    <!-- Simple reactive flag -->
    <NewDashboard v-if="isNewDashboardEnabled" />
    <OldDashboard v-else />
    
    <!-- Conditional admin panel -->
    <AdminPanel v-if="isAdminPanelEnabled" />
  </div>
</template>

<script setup>
// Individual flags with autocompletion
const isNewDashboardEnabled = useFeatureFlag('new-dashboard')
const isAdminPanelEnabled = useFeatureFlag('admin-panel')

// Full API access
const { isEnabled, updateContext } = useFeatureFlags()

// Update context when user changes (e.g., with nuxt-auth-utils)
const { data: user } = await useAuthUser()
watch(user, (newUser) => {
  updateContext({ user: newUser })
})
</script>

📖 Configuration

Basic Configuration

// nuxt.config.ts
export default defineNuxtConfig({
  flagkit: {
    debug: true, // Enable debug logging
    flags: {
      'feature-name': {
        enabled: true,
        description: 'Description of the feature',
        envVar: 'FEATURE_NAME' // Environment variable override
      }
    }
  }
})

Environment Variable Overrides

You can override any flag using environment variables:

# .env
FEATURE_NEW_DASHBOARD=true
FEATURE_BETA=false

Flexible Rule-Based Evaluation

The rule system allows you to create dynamic feature flags based on any context:

flags: {
  'admin-features': {
    enabled: false,
    rules: [
      {
        path: 'user.role',
        operator: 'equals',
        value: 'admin'
      }
    ]
  },
  'team-features': {
    enabled: false,
    rules: [
      {
        path: 'team.plan',
        operator: 'in',
        value: ['premium', 'enterprise']
      }
    ]
  },
  'subscription-features': {
    enabled: false,
    rules: [
      {
        path: 'subscription.status',
        operator: 'equals',
        value: 'active'
      },
      {
        path: 'subscription.plan',
        operator: 'equals',
        value: 'pro'
      }
    ]
  },
  'email-domain-feature': {
    enabled: false,
    rules: [
      {
        path: 'user.email',
        operator: 'endsWith',
        value: '@company.com'
      }
    ]
  }
}

🎯 Rule System

Available Operators

  • equals - Exact match
  • contains - String contains substring
  • endsWith - String ends with substring
  • startsWith - String starts with substring
  • in - Value is in array
  • exists - Property exists and is not null/undefined
  • gt - Greater than (numeric)
  • lt - Less than (numeric)
  • gte - Greater than or equal (numeric)
  • lte - Less than or equal (numeric)
  • modulo - Modulo operation for percentage rollouts

Path-Based Evaluation

The path property uses dot notation to access nested properties in your context:

// Context
{
  user: {
    id: 123,
    email: '[email protected]',
    role: 'admin',
    profile: {
      subscription: {
        plan: 'pro',
        status: 'active'
      }
    }
  },
  team: {
    id: 456,
    plan: 'enterprise'
  }
}

// Rules
{
  path: 'user.role',              // → 'admin'
  path: 'user.profile.subscription.plan', // → 'pro'
  path: 'team.plan',              // → 'enterprise'
}

Multiple Rules (AND Logic)

When multiple rules are defined, ALL rules must pass for the flag to be enabled:

'premium-feature': {
  enabled: false,
  rules: [
    {
      path: 'subscription.status',
      operator: 'equals',
      value: 'active'
    },
    {
      path: 'subscription.plan',
      operator: 'in',
      value: ['pro', 'enterprise']
    }
  ]
}

🔧 API Reference

useFeatureFlags()

Main composable for feature flag management:

const { isEnabled, getFlags, updateContext, refresh } = useFeatureFlags()

// Check if a flag is enabled
const enabled = isEnabled('feature-name')

// Get all flags
const allFlags = getFlags()

// Update context (triggers re-evaluation)
updateContext({ 
  user: newUser,
  team: newTeam,
  subscription: newSubscription
})

// Manually refresh all flags
refresh()

useFeatureFlag(flagName)

Simple composable for individual flags:

// Returns a reactive boolean
const isEnabled = useFeatureFlag('feature-name')

// Use in template
<div v-if="isEnabled">Feature content</div>

🎨 Examples

Percentage Rollouts

'gradual-rollout': {
  enabled: false,
  rules: [
    {
      path: 'user.id',
      operator: 'modulo',
      value: { divisor: 100, remainder: 0 } // 1% of users
    }
  ]
}

A/B Testing

'variant-a': {
  enabled: false,
  rules: [
    {
      path: 'user.id',
      operator: 'modulo',
      value: { divisor: 2, remainder: 0 } // 50% of users
    }
  ]
},
'variant-b': {
  enabled: false,
  rules: [
    {
      path: 'user.id',
      operator: 'modulo',
      value: { divisor: 2, remainder: 1 } // Other 50% of users
    }
  ]
}

Complex Business Logic

'enterprise-feature': {
  enabled: false,
  rules: [
    {
      path: 'team.plan',
      operator: 'equals',
      value: 'enterprise'
    },
    {
      path: 'user.role',
      operator: 'in',
      value: ['admin', 'owner']
    },
    {
      path: 'subscription.status',
      operator: 'equals',
      value: 'active'
    }
  ]
}
  • Clone this repository
  • Install latest LTS version of Node.js
  • Enable Corepack using corepack enable
  • Install dependencies using pnpm install
  • Start development server using pnpm dev
  • Open http://localhost:3000 in your browser

Sponsors

Published under the APACHE license. Made by @HugoRCD and community 💛


🤖 auto updated with automd (last updated: Wed May 28 2025)