persist-secure-store
Persist small secrets with Expo SecureStore via @stainless-code/persist/backends/secure-store. ~2KB/key — use partialize; async → useHydrated.
- License 许可
- MIT
- 最近更新
- 2026-11-01
- Stars
- ★ 5
- Forks
- 0
01 前言 Front Matter
- name
- persist-secure-store
- license
- MIT
- sources
- [ "stainless-code/persist:src/adapters/backends/secure-store.ts" ]
- metadata
- { "type": "composition", "library": "@stainless-code/persist", "framework": "expo-secure-store", "library_version": "0.4.1" }
- requires
- [ "persist" ]
- description
- Persist small secrets with Expo SecureStore via @stainless-code/persist/backends/secure-store. ~2KB/key — use partialize; async → useHydrated.
03 SKILL.md 正文
SecureStore backend
For tokens / small secrets, not full app state (~2KB/key). Async → gate UI. Keys sanitized to /^[\w.-]+$/ (: → _).
Install
bun add @stainless-code/persist expo-secure-store zustand
Peers: expo-secure-store >=12.0.0; example uses zustand (any ./sources/* adapter works).
Minimal wiring
import { create } from "zustand";
import { createSecureStoreStorage } from "@stainless-code/persist/backends/secure-store";
import { persistStore } from "@stainless-code/persist/sources/zustand";
type Auth = { token: string };
const useAuth = create<Auth>(() => ({ token: "" }));
const storage = createSecureStoreStorage<string>()!;
persistStore(useAuth, {
name: "auth:token:v1",
storage,
partialize: (s) => s.token,
});
Common mistakes
- Storing large documents — wrong backend.
- Skipping
partialize. - Assuming colon keys are stored literally.
API surface
createSecureStoreStorage()·secureStoreStateStorage()
See also: persist-mmkv; persist-encrypted.
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.
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.