What problem does this feature solve?
Allow projects to load feature flags from an external config file instead of keeping them inline in nuxt.config.ts. This improves maintainability, supports reuse across projects, and keeps nuxt.config.ts clean.
Usage
In nuxt.config.ts
export default defineNuxtConfig({
modules: ['nuxt-feature-flags-module'],
featureFlags: {
configFile: './feature-flags.config.ts',
mergeStrategy: 'merge', // optional: 'merge' (default) | 'replace'
}
})
In feature-flags.config.ts
import { defineFeatureFlags } from 'nuxt-feature-flags-module/helpers'
export default defineFeatureFlags({
environment: 'staging',
flagSets: {
development: ['solutions/*'],
staging: ['solutions/company-portal/*'],
production: ['solutions/company-portal/addons/sales'],
},
validation: {
mode: 'warn',
},
})
Behavior
configFile → path to external config file (relative to project root).
mergeStrategy →
merge (default): combine external + inline flags (inline wins on conflicts).
replace: ignore inline flags, use only external config.
- External config must default export an object created with
defineFeatureFlags().
- Dev mode: file changes are watched and re-validated automatically.
Benefits
- Keeps
nuxt.config.ts clean.
- Easier to maintain hundreds of flags.
- Share one flags file across multiple apps.
- Fully type-safe with
defineFeatureFlags().
What problem does this feature solve?
Allow projects to load feature flags from an external config file instead of keeping them inline in
nuxt.config.ts. This improves maintainability, supports reuse across projects, and keepsnuxt.config.tsclean.Usage
In
nuxt.config.tsIn
feature-flags.config.tsBehavior
configFile→ path to external config file (relative to project root).mergeStrategy→merge(default): combine external + inline flags (inline wins on conflicts).replace: ignore inline flags, use only external config.defineFeatureFlags().Benefits
nuxt.config.tsclean.defineFeatureFlags().