
Security News
npm ‘is’ Package Hijacked in Expanding Supply Chain Attack
The ongoing npm phishing campaign escalates as attackers hijack the popular 'is' package, embedding malware in multiple versions.
nuxt-feature-flags
Advanced tools
A powerful, type-safe feature flag module for Nuxt 3 that enables both static and dynamic feature flag evaluation with server-side support. Perfect for A/B testing, gradual rollouts, and feature management.
[!WARNING] This project is just getting started, so things are gonna change a lot. Updates will roll out often, and we're totally open to feedback—hit us up with your thoughts!
# Using npx
npx nuxi module add nuxt-feature-flags
# Using npm
npm install nuxt-feature-flags
# Using yarn
yarn add nuxt-feature-flags
# Using pnpm
pnpm add nuxt-feature-flags
nuxt.config.ts
:// Basic usage with plain configuration
export default defineNuxtConfig({
modules: ['nuxt-feature-flags'],
featureFlags: {
flags: {
newDashboard: false,
experimentalFeature: true
}
}
})
// Advanced usage with context-based flag rules
// feature-flags.config.ts
import { defineFeatureFlags } from '#feature-flags/handler'
export default defineFeatureFlags((context) => {
return {
isAdmin: context?.user?.role === 'admin',
newDashboard: true,
experimentalFeature: process.env.NODE_ENV === 'development',
betaFeature: context?.user?.isBetaTester ?? false,
}
})
// nuxt.config.ts
export default defineNuxtConfig({
featureFlags: {
config: './feature-flags.config.ts',
}
})
<script setup>
const { isEnabled } = useFeatureFlags()
</script>
<template>
<div>
<NewDashboard v-if="isEnabled('newDashboard')" />
</div>
</template>
// server/api/dashboard.ts
export default defineEventHandler(async (event) => {
const { isEnabled } = getFeatureFlags(event)
if (!isEnabled('newDashboard')) {
throw createError({
statusCode: 404,
message: 'Dashboard not available'
})
}
return {
stats: {
users: 100,
revenue: 50000
}
}
})
const {
flags, // Reactive flags object
isEnabled, // (flagName: string) => boolean
} = useFeatureFlags()
// Check if a flag is enabled
if (isEnabled('newFeature')) {
// Feature is enabled
}
const {
flags, // Flags object
isEnabled, // (flagName: string) => boolean
} = getFeatureFlags(event)
// Check if a flag is enabled
if (isEnabled('newFeature')) {
// Feature is enabled
}
export default defineNuxtConfig({
featureFlags: {
flags: {
promoBanner: true,
betaFeature: false,
newDashboard: false
}
}
})
// nuxt.config.ts
export default defineNuxtConfig({
featureFlags: {
config: './feature-flags.config.ts',
}
})
// feature-flags.config.ts
import { defineFeatureFlags } from '#feature-flags/handler'
export default defineFeatureFlags(() => ({
isAdmin: false,
newDashboard: true,
experimentalFeature: true,
promoBanner: false,
betaFeature: false,
}))
// feature-flags.config.ts
import { defineFeatureFlags } from '#feature-flags/handler'
export default defineFeatureFlags((context) => {
return {
// User role-based flag
isAdmin: context?.user?.role === 'admin',
// Environment-based flag
devTools: process.env.NODE_ENV === 'development',
// User status-based flag
betaFeature: context?.user?.isBetaTester ?? false,
// Device-based flag
mobileFeature: context?.device?.isMobile ?? false,
}
})
npm install
npm run dev
Thanks goes to these wonderful people (emoji key):
Roberth González 💻 | Eugen Istoc 💻 | Daniel Roe 📖 |
This project follows the all-contributors specification. Contributions of any kind welcome!
MIT License © 2025 Roberth González
FAQs
Feature flags for Nuxt
The npm package nuxt-feature-flags receives a total of 68 weekly downloads. As such, nuxt-feature-flags popularity was classified as not popular.
We found that nuxt-feature-flags demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
The ongoing npm phishing campaign escalates as attackers hijack the popular 'is' package, embedding malware in multiple versions.
Security News
A critical flaw in the popular npm form-data package could allow HTTP parameter pollution, affecting millions of projects until patched versions are adopted.
Security News
Bun 1.2.19 introduces isolated installs for smoother monorepo workflows, along with performance boosts, new tooling, and key compatibility fixes.