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.
- License 许可
- MIT
- 最近更新
- 2026-11-01
- Stars
- ★ 5
- Forks
- 0
01 前言 Front Matter
- name
- svelte-persist
- license
- MIT
- sources
- [ "stainless-code/persist:src/adapters/frameworks/svelte.ts" ]
- metadata
- { "type": "framework", "library": "@stainless-code/persist", "framework": "svelte", "library_version": "0.4.1" }
- requires
- [ "persist" ]
- description
- Gate Svelte 5 runes UI on Persist hydration with hydratedRune (.current). Use for Svelte 5; for stores / Svelte 3–4 use svelte-store-persist.
03 SKILL.md 正文
Svelte 5 runes hydration gate
@stainless-code/persist/frameworks/svelte exports hydratedRune(signal) → { readonly current: boolean }. Read .current inside $derived / $effect / {#if} (createSubscriber is lazy inside a reactive owner).
Stores / Svelte 3–4 / Svelte 5 store users → svelte-store-persist (./frameworks/svelte-store).
Install
bun add @stainless-code/persist svelte
Needs Svelte 5.7+ for svelte/reactivity createSubscriber (package peer allows >=3 because of the separate store entry).
Minimal wiring
<script>
import { hydratedRune } from "@stainless-code/persist/frameworks/svelte";
const hydrated = hydratedRune(prefsHydration);
</script>
{#if !hydrated.current}
<Skeleton />
{:else}
<Prefs />
{/if}
Contracts
Null/undefined → current: true. SSR: hydrated true.
Common mistakes
- Using this entry for store-based UI. Import
svelte-store-persist. - Reading
.currentoutside a reactive owner — subscribe is a no-op. - Expecting a
useHydratedname — runes API ishydratedRune.
API surface
hydratedRune(signal) → { readonly current: boolean }
See also: svelte-store-persist.
04 同仓库更多 Skills
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.
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.
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.