Skip to content

@stainless-code/persist

Hydration-aware persistence for any reactive store — zero-dep persistSource core; codecs, backends, cross-tab transport, source + framework hydration adapters ship as opt-in recipes

solid-persist

50 linesSource

Gate Solid UI on Persist hydration with useHydrated (Accessor). Use when avoiding flash of default state on async backends; read hydrated() in reactive scopes.

Solid hydration gate

@stainless-code/persist/frameworks/solid returns an Accessor<boolean> — call hydrated() inside tracking scopes (createEffect, JSX, …).

Install

shell
bun add @stainless-code/persist solid-js

Peer: solid-js >=1.6.0.

Minimal wiring

tsx
import { useHydrated } from "@stainless-code/persist/frameworks/solid";

const hydrated = useHydrated(prefsHydration);
// <Show when={hydrated()} fallback={<Skeleton />}>…</Show>

Contracts

Null/undefined signal → hydrated true. SSR policy: treat as hydrated true.

Common mistakes

  • Using hydrated as a boolean — it's an accessor; call it.
  • Reading outside a reactive scope — won't update.
  • Null signal ≠ loading → hydrated true.

API surface

  • useHydrated(signal) → Accessor<boolean>