Composables
useXAdminFeatureFlags
Manages global feature flags with CRUD actions, per-plan overrides, and an isEnabled resolver for runtime evaluation.
useXAdminFeatureFlags
Feature flag composable. Wraps the /api/admin/feature-flags/* endpoints with CRUD actions and a client-side resolver. Flag shape: { id, key, name, description, enabled, defaultValue, overrides }, where overrides is an optional array of per-plan targeting entries ([{ plan, enabled }]). Pairs with XAdminFeatureFlags for the list view and XAdminFeatureFlagsEditor for the create/edit form.
Uses the useXCrud v2 factory API from @xenterprises/nuxt-x-app — the returned flags is a v2 list instance (useXCrud("admin/feature-flags").all()). Filter by assigning flags.filters.value and reload with await flags.refresh(); there is no .fetch(params).
Usage
const featureFlags = useXAdminFeatureFlags()
featureFlags.flags.data.value
await featureFlags.createFlag({ key: "new-checkout", name: "New Checkout", enabled: true })
await featureFlags.updateFlag(flagId, { enabled: false })
await featureFlags.toggleFlag(flag)
await featureFlags.deleteFlag(flagId)
featureFlags.getFlag("new-checkout")
featureFlags.isEnabled("new-checkout", { plan: "pro" })
Options
| Option | Type | Default | Description |
|---|---|---|---|
baseEndpoint | string | 'admin/feature-flags' | API endpoint base the composable calls. |
showToast | boolean | true | Show toast notifications on success/failure. |
Returns
| Key | Type | Description |
|---|---|---|
flags | useXCrud v2 list instance | Reactive flag list: { data, total, filters, search, sort, loading, error, refresh, create, update, remove, ... }. |
createFlag | (payload: object) => Promise<void> | Creates a new feature flag and refreshes the list. |
updateFlag | (flagId: string, payload: object) => Promise<void> | Updates a flag and refreshes the list. |
toggleFlag | (flag: object) => Promise<void> | Flips a flag's enabled master switch. |
deleteFlag | (flagId: string) => Promise<void> | Deletes a flag and refreshes the list. |
getFlag | (key: string) => object | null | Finds a flag by its key. |
isEnabled | (key: string, context?: { plan?: string }) => boolean | Resolves the effective value: master switch wins, then a matching plan override, then defaultValue (defaults to true when unset). |
AI Context
composable: useXAdminFeatureFlags
package: "@xenterprises/nuxt-x-app-admin"
use-when: >
Managing global feature flags — creating, updating, toggling, or deleting
flags with optional per-plan overrides, or evaluating whether a flag is
enabled for a given context. Uses /api/admin/feature-flags/* endpoints and
the useXCrud v2 factory API (filters-assignment + refresh(), no .fetch(params)).
pairs-with: XAdminFeatureFlags, XAdminFeatureFlagsEditor
