persist-mmkv
Persist with react-native-mmkv via @stainless-code/persist/backends/mmkv (createMmkvStorage). Sync JSON string-wire; id required; optional MMKV encryptionKey (≤16 bytes).
- License 许可
- MIT
- 最近更新
- 2026-11-01
- Stars
- ★ 5
- Forks
- 0
01 前言 Front Matter
- name
- persist-mmkv
- license
- MIT
- sources
- [ "stainless-code/persist:src/adapters/backends/mmkv.ts" ]
- metadata
- { "type": "composition", "library": "@stainless-code/persist", "framework": "react-native-mmkv", "library_version": "0.4.1" }
- requires
- [ "persist" ]
- description
- Persist with react-native-mmkv via @stainless-code/persist/backends/mmkv (createMmkvStorage). Sync JSON string-wire; id required; optional MMKV encryptionKey (≤16 bytes).
03 SKILL.md 正文
MMKV backend
Sync backend — no hydrate UI gate required for flash. JSON string-wire. id namespaces the MMKV file. encryptionKey is MMKV's own key (max 16 bytes), not persist-encrypted.
Install
bun add @stainless-code/persist react-native-mmkv
Peer: react-native-mmkv >=4.0.0.
Minimal wiring
import { createMmkvStorage } from "@stainless-code/persist/backends/mmkv";
const storage = createMmkvStorage<Prefs>({ id: "app-prefs" })!;
Common mistakes
- Gating like IDB — MMKV is sync.
- Confusing
encryptionKeywithbackends/encrypted. - Omitting
id.
API surface
createMmkvStorage({ id, path?, encryptionKey? })·mmkvStateStorage(instance)
See also: persist-async-storage; persist-encrypted for WebCrypto AES-GCM.
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.