Registry / storage / react-native-mmkv-storage

react-native-mmkv-storage

JSON →
library12.0.1jsnpmunverified

A fast and reliable key-value storage library for React Native, wrapping Tencent's MMKV (used by WeChat). Version 12.0.1 is current, with updates driven by RN breaking changes. It uses JSI for synchronous C++ operations (no async gaps), supports multiple encrypted instances, and ships TypeScript types. Unlike async-storage or simple MMKV wrappers, it offers React hooks (useMMKVStorage, useIndex) and 0.0002s read/write. Released under MIT, maintained on GitHub.

npm install react-native-mmkv-storage
INSTALL
IMPORT
SIG · REACT-NATIVE-MMKV-
R
react-native-mmkv-storage
storagejavascriptv12.0.1
harness data pending
Install & Compatibility
Where this runs

No compatibility data collected yet for this library.

Code
Verified usage

Verified import paths — ran on the pinned version, not inferred.

MMKVLoader
import { MMKVLoader } from 'react-native-mmkv-storage'
import MMKVLoader from 'react-native-mmkv-storage'
Named export, not default. Use destructured import.
useMMKVStorage
import { useMMKVStorage } from 'react-native-mmkv-storage'
import { useMMKVStorage } from 'react-native-mmkv-storage/hooks'
Hook is exported from root package, not a sub-path.
MMKV
import { MMKV } from 'react-native-mmkv-storage'
import { MMKV } from 'react-native-mmkv-storage/MMKV'
MMKV is the instance returned by MMKVLoader().initialize(). It is exported directly.

Shows initialization with MMKVLoader, useMMKVStorage hook for reactive state, and sync set. Typescript works without extra types.

import { MMKVLoader, useMMKVStorage } from 'react-native-mmkv-storage'; const storage = new MMKVLoader().initialize(); function App() { const [name, setName] = useMMKVStorage('name', storage, 'Guest'); const [count, setCount] = useMMKVStorage('count', storage, 0); return ( <View> <Text>Hello, {name}!</Text> <Text>Count: {count}</Text> <Button title="Increment" onPress={() => setCount(c => c + 1)} /> </View> ); }
Debug
Known issues
breakingv0.9.0 requires React Native >= 0.71.0
fix
Upgrade to React Native 0.71+ or stick with v0.8.x
affects: >=0.9.0
breakingv0.5.0 rewritten in C++ using JSI, breaking older versions
fix
Re-link native modules and update initialization to new MMKVLoader API
affects: >=0.5.0
deprecatedv0.6.0 deprecated older initializer patterns like 'new MMKVStorage.Loader()'
fix
Use 'new MMKVLoader().initialize()' instead
affects: >=0.6.0
gotchauseMMKVStorage hook only works inside React components; outside component context use storage methods directly
fix
Use storage.getString('key') outside components, not hook
affects: >=0.5.5
gotchaEncryption requires passing a password to MMKVLoader.setEncryptionKey() before initialize()
fix
Always call setEncryptionKey() before initialize() if you need encryption. Cannot change later.
affects: >=0.5.0
Errors
Common errors & fixes
TypeError: Cannot read property 'getString' of undefined
storage instance not initialized or imported incorrectly (e.g., missing .initialize() or using wrong import pattern)
fix
Ensure you call 'new MMKVLoader().initialize()' and check import: use '{ MMKVLoader }' not default import.
Invariant Violation: Tried to register two views with the same name
Duplicated native module registration (often due to linking both old and new versions)
fix
Run 'cd ios && pod deintegrate && pod install' and ensure only one version of MMKVStorage is in node_modules.
fatal: Not a git repository (or any of the parent directories): .git
Running pod install without git repository
fix
Initialize a git repo with 'git init' before 'pod install' or add '--no-repo-update'
React Native version mismatch. JavaScript version: 0.73.4, Native version: 0.72.0
MMKV native library compiled for different RN version
fix
Update both React Native and MMKVStorage to compatible versions, run pod install again.
Upgrade
Version history
12.0.1latest on npm
Audit
Dependencies
react-nativerequiredpeer dependency - requires React Native runtime
Agent activity
28 hits · last 30 days
node
26
OpenAI (training)
1
Resources
react-native-mmkv-storage — npm install react-native-mmkv-storage · libregistry