Skip to content

feat(useFeatures): add persist option#388

Open
johnleider wants to merge 2 commits into
masterfrom
feat-features-persist
Open

feat(useFeatures): add persist option#388
johnleider wants to merge 2 commits into
masterfrom
feat-features-persist

Conversation

@johnleider

Copy link
Copy Markdown
Member

Adds a persist option to createFeaturesPlugin, closing the gap that left useFeatures as the only user-state plugin without persistence (useTheme, useRtl, useReducedMotion, useLocale already have it).

feat(useFeatures)

createFeaturesPlugin({ persist: true }) saves the set of enabled feature flags to storage and reconciles them against the registered flags on load, so a user's toggles survive a reload. Implemented via the existing createPluginContext persist/restore hooks; the selected flag ids round-trip through storage keyed by the plugin namespace (v0:features).

docs cleanup (the payoff)

The docs app was hand-rolling devmode persistence in two places — a manual localStorage read in zero.ts and a duplicated watch(() => devmode.isSelected.value, …) → storage.set('devmode') in both AppBar.vue and AppSettingsSheet.vue. All of it is removed in favor of persist: true.

Verified end-to-end on the docs app: toggling devmode writes v0:features, and a reload restores the selection (the devmode-gated /health nav link reappears).

Note: the storage key moves from the old v0:devmode boolean to v0:features (an id array), so an existing devmode toggle resets once on first load after upgrade.

Setting persist: true saves the set of enabled feature flags to storage and
reconciles them against the registered flags on load, so a user's feature
toggles survive a page reload. Wires the existing createPluginContext
persist/restore hooks; the selected flag ids round-trip through storage keyed
by the plugin namespace.
Drops the hand-rolled devmode persistence (manual localStorage read in
zero.ts and duplicate watch+storage.set in AppBar and AppSettingsSheet) in
favor of createFeaturesPlugin({ persist: true }).
@johnleider johnleider added this to the v1.1.0 milestone Jun 25, 2026
@johnleider johnleider added documentation Improvements or additions to documentation enhancement New feature or request labels Jun 25, 2026
@johnleider johnleider self-assigned this Jun 25, 2026
@pkg-pr-new

pkg-pr-new Bot commented Jun 25, 2026

Copy link
Copy Markdown

Open in StackBlitz

commit: 6c0965e

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

documentation Improvements or additions to documentation enhancement New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant