vue-persist
Gate Vue 3 UI on Persist hydration with useHydrated (shallowRef). Use in setup/effectScope when avoiding flash of default state on async backends.
- License 许可
- MIT
- 最近更新
- 2026-11-01
- Stars
- ★ 5
- Forks
- 0
01 前言 Front Matter
- name
- vue-persist
- license
- MIT
- sources
- [ "stainless-code/persist:src/adapters/frameworks/vue.ts" ]
- metadata
- { "type": "framework", "library": "@stainless-code/persist", "framework": "vue", "library_version": "0.4.1" }
- requires
- [ "persist" ]
- description
- Gate Vue 3 UI on Persist hydration with useHydrated (shallowRef). Use in setup/effectScope when avoiding flash of default state on async backends.
03 SKILL.md 正文
Vue hydration gate
@stainless-code/persist/frameworks/vue returns a Ref<boolean> (shallowRef). Call inside setup() / an active effectScope() so onScopeDispose unsubscribes.
Install
bun add @stainless-code/persist vue
Peer: vue >=3.3.0.
Minimal wiring
import { toHydrationSignal } from "@stainless-code/persist";
import { useHydrated } from "@stainless-code/persist/frameworks/vue";
const prefsHydration = toHydrationSignal(persist);
// in setup():
const hydrated = useHydrated(prefsHydration);
<Skeleton v-if="!hydrated" />
<PrefsPanel v-else />
Common mistakes
- Calling outside setup / scope — leak or no teardown.
- Treating the ref as store state.
- SSR / null signal. Null stays
true; there is no separate server snapshot (unlike ReactgetServerSnapshot).
API surface
useHydrated(signal) → Ref<boolean>
See also: persist-pinia for Pinia store wiring.
04 同仓库更多 Skills
svelte-store-persist
Gate Svelte store-based UI on Persist hydration with hydratedStore (Readable). Use for Svelte 3–4 or Svelte 5 apps that still use stores; runes UI → svelte-persist.
svelte-persist
Gate Svelte 5 runes UI on Persist hydration with hydratedRune (.current). Use for Svelte 5; for stores / Svelte 3–4 use svelte-store-persist.
solid-persist
Gate Solid UI on Persist hydration with useHydrated (Accessor). Use when avoiding flash of default state on async backends; read hydrated() in reactive scopes.
react-persist
Gate React UI on Persist hydration with useHydrated + toHydrationSignal. Use when avoiding flash of default state on async backends (IndexedDB), SSR snapshot true, or wiring HydrationSignal into React 18/19.
preact-persist
Gate Preact UI on Persist hydration with useHydrated (preact/compat useSyncExternalStore). Use when avoiding flash of default state on async backends or wiring HydrationSignal into Preact.
persist
Core @stainless-code/persist concepts — persistSource, PersistOptions, PersistApi, hydration gate, throttle, cross-tab, migrate. Load before framework hydration skills or when wiring a custom PersistableSource.