@stainless-code/persist
persist-mmkv
47 linesSource
Persist with react-native-mmkv via @stainless-code/persist/backends/mmkv (createMmkvStorage). Sync JSON string-wire; id required; optional MMKV encryptionKey (≤16 bytes).
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
shell
bun add @stainless-code/persist react-native-mmkvPeer: react-native-mmkv >=4.0.0.
Minimal wiring
ts
import { createMmkvStorage } from "@stainless-code/persist/backends/mmkv";
const storage = createMmkvStorage<Prefs>({ id: "app-prefs" })!;Common mistakes
- Gating like IDB — MMKV is sync.
- Confusing encryptionKey with backends/encrypted.
- Omitting id.
API surface
- createMmkvStorage({ id, path?, encryptionKey? }) · mmkvStateStorage(instance)
See also: persist-async-storage; persist-encrypted for WebCrypto AES-GCM.