
Security News
npm Adopts OIDC for Trusted Publishing in CI/CD Workflows
npm now supports Trusted Publishing with OIDC, enabling secure package publishing directly from CI/CD workflows without relying on long-lived tokens.
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.
# 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 type { H3EventContext } from 'h3'
export default function featureFlagsConfig(context?: H3EventContext) {
return {
isAdmin: context?.user?.role === 'admin',
newDashboard: true,
experimentalFeature: process.env.NODE_ENV === 'development',
betaFeature: context?.user?.isBetaTester ?? false,
}
}
<script setup>
const { isEnabled } = useClientFlags()
</script>
<template>
<div>
<NewDashboard v-if="isEnabled('newDashboard')" />
</div>
</template>
// server/api/dashboard.ts
export default defineEventHandler(async (event) => {
const { isEnabled } = await useServerFlags(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
} = useClientFlags()
// Check if a flag is enabled
if (isEnabled('newFeature')) {
// Feature is enabled
}
const {
flags, // Flags object
isEnabled, // (flagName: string) => boolean
} = await useServerFlags(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
export default {
isAdmin: false,
newDashboard: true,
experimentalFeature: true,
promoBanner: false,
betaFeature: false,
}
// feature-flags.config.ts
import type { H3EventContext } from 'h3'
export default function featureFlagsConfig(context?: H3EventContext) {
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
Thanks goes to these wonderful people (emoji key):
This project follows the all-contributors specification. Contributions of any kind welcome!
FAQs
Feature flags for Nuxt
The npm package nuxt-feature-flags receives a total of 119 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
npm now supports Trusted Publishing with OIDC, enabling secure package publishing directly from CI/CD workflows without relying on long-lived tokens.
Research
/Security News
A RubyGems malware campaign used 60 malicious packages posing as automation tools to steal credentials from social media and marketing tool users.
Security News
The CNA Scorecard ranks CVE issuers by data completeness, revealing major gaps in patch info and software identifiers across thousands of vulnerabilities.