Gathering detailed insights and metrics for react-native-mmkv-storage
Gathering detailed insights and metrics for react-native-mmkv-storage
Gathering detailed insights and metrics for react-native-mmkv-storage
Gathering detailed insights and metrics for react-native-mmkv-storage
react-native-mmkv
The fastest key/value storage for React Native. ~30x faster than AsyncStorage! Works on Android, iOS and Web.
@react-native-oh-tpl/react-native-mmkv-storage
This library aims to provide a fast & reliable solution for you data storage needs in react-native apps. It uses [MMKV](https://github.com/Tencent/MMKV) by Tencent under the hood on Android and iOS both that is used by their WeChat app(more than 1 Billion
flipper-plugin-react-native-mmkv-storage
Developer tools for React Native MMKV Storage
tfjs-react-native-mmkv-storage
MMKV storage IO for tfjs react native based on react-native-mmkv
An ultra fast (0.0002s read/write), small & encrypted mobile key-value storage framework for React Native written in C++ using JSI
npm install react-native-mmkv-storage
Typescript
Module System
Node Version
NPM Version
C++ (65.6%)
TypeScript (10.8%)
Assembly (5.44%)
Objective-C++ (4.75%)
C (4.51%)
Java (4.28%)
Objective-C (2.2%)
CMake (1.25%)
Kotlin (0.43%)
Ruby (0.4%)
JavaScript (0.32%)
Swift (0.01%)
Total Downloads
0
Last Day
0
Last Week
0
Last Month
0
Last Year
0
MIT License
1,700 Stars
868 Commits
119 Forks
15 Watchers
18 Branches
47 Contributors
Updated on Jul 13, 2025
Latest Version
0.11.2
Package Id
react-native-mmkv-storage@0.11.2
Unpacked Size
945.17 kB
Size
226.56 kB
File Count
200
NPM Version
10.5.2
Node Version
20.12.2
Published on
Nov 03, 2024
Cumulative downloads
Total Downloads
Last Day
0%
NaN
Compared to previous day
Last Week
0%
NaN
Compared to previous week
Last Month
0%
NaN
Compared to previous month
Last Year
0%
NaN
Compared to previous year
npm install react-native-mmkv-storage
expo prebuild
This library aims to provide a fast & reliable solution for you data storage needs in react-native apps. It uses MMKV by Tencent under the hood on Android and iOS both that is used by their WeChat app(more than 1 Billion users). Unlike other storage solutions for React Native, this library lets you store any kind of data type, in any number of database instances, with or without encryption in a very fast and efficient way. Read about it on this blog post I wrote on dev.to
Learn how to build your own module with JSI on my blog
Works only with react native 0.71.0 and above. If you are on older version of react native, keep using 0.8.x.
Starting from v0.5.0
the library has been rewritten in C++ on Android and iOS both. It employs React Native JSI making it the fastest storage option for React Native.
(~ 50K Android/30K iOS) and even smaller when packaged.
MMKV uses mmap to keep memory synced with file, and protobuf to encode/decode values to achieve best performance. You can see the benchmarks here: Android & iOS
useMMKVStorage
& useIndex
HooksHooks let's the storage update your app when a change takes place in storage.
useMMKVStorage
hookStarting from v0.5.5
, thanks to the power of JSI, we now have our very own useMMKVStorage
Hook. Think of it like a persisted state that will always write every change in storage and update your app UI instantly. It doesn't matter if you reload the app or restart it.
1import { MMKVLoader, useMMKVStorage } from 'react-native-mmkv-storage'; 2 3const storage = new MMKVLoader().initialize(); 4const App = () => { 5 const [user, setUser] = useMMKVStorage('user', storage, 'robert'); 6 const [age, setAge] = useMMKVStorage('age', storage, 24); 7 8 return ( 9 <View style={styles.header}> 10 <Text style={styles.headerText}> 11 I am {user} and I am {age} years old. 12 </Text> 13 </View> 14 ); 15};
Learn more about useMMKVStorage
hook it in the docs.
useIndex
hookA hook that will take an array of keys and returns an array of values for those keys. This is supposed to work in combination with Transactions. When you have build your custom index, you will need an easy and quick way to load values for your index. useIndex hook actively listens to all read/write changes and updates the values accordingly.
1const App = () => { 2 // Get list of all post ids 3 const postsIndex = useMMKVStorage("postsIndex",storage,[]); // ['post123','post234']; 4 // Get the posts based on those ids. 5 const [posts,update,remove] = useIndex(postsIndex,"object" storage); 6 7 return <View> 8 <FlatList 9 data={posts} 10 renderItem={...} 11 > 12</View> 13 14}
Learn more about useIndex
hook it in the docs.
Listen to a value's lifecycle and mutate it on the go. Transactions lets you register lifecycle functions with your storage instance such as Read, Write and Delete. This allows for a better and more managed control over the storage and also let's you build custom indexes with a few lines of code.
1MMKV.transactions.register('object', 'beforewrite', ({ key, value }) => {
2 if (key.startsWith('post.')) {
3 // Call this only when the key has the post prefix.
4 let indexForTag = MMKV.getArray(`${value.tag}-index`) || [];
5 MMKV.setArray(indexForTag.push(key));
6 }
7});
Learn more about how to use Transactions in docs
MMKV supports concurrent read-read and read-write access between processes. This means that you can use MMKV for various extensions and widgets and your app.
You can create many database instances. This helps greatly if you have separate logics/modules in the same app that use data differently, It also helps in better performance since each database instance is small instead of a single bulky database which makes things slower as it grows.
1const userStorage = new MMKVLoader().withEncryption().withInstanceID('userdata').initialize();
2
3const settingsStorage = new MMKVLoader().withInstanceID('settings').initialize();
The library supports full encryption (AES CFB-128) on Android and iOS. You can choose to store your encryption key securely for continuious usage. The library uses Keychain on iOS and Android Keystore on android (API 23 and above). Encrypting an instance is simple:
1const storage = new MMKVLoader()
2 .withEncryption() // Generates a random key and stores it securely in Keychain
3 .initialize();
And that's it.
For each database instance, there is one global key index and then there are indexes of each type of data. So querying is easy and fast.
Support for redux persist is also added starting from v0.3.2.
You can use this library with expo bare workflow.
Thanks to pnthach95 Flipper plugin is finally here. https://github.com/pnthach95/flipper-plugin-react-native-mmkv-storage. It supports logging and manipulating storage values on the fly.
If you are using the library in one of your projects, consider supporting with a star. It takes a lot of time and effort to keep this maintained and address issues and bugs. Thank you.
That is awesome news! There is a lot happening at a very fast pace in this library right now. Every little help is precious. You can contribute in many ways:
This library is licensed under the MIT license.
Copyright © Ammar Ahmed (@ammarahm-ed)
No vulnerabilities found.
Reason
no dangerous workflow patterns detected
Reason
license file detected
Details
Reason
binaries present in source code
Details
Reason
4 existing vulnerabilities detected
Details
Reason
dependency not pinned by hash detected -- score normalized to 5
Details
Reason
Found 4/25 approved changesets -- score normalized to 1
Reason
0 commit(s) and 0 issue activity found in the last 90 days -- score normalized to 0
Reason
detected GitHub workflow tokens with excessive permissions
Details
Reason
no effort to earn an OpenSSF best practices badge detected
Reason
security policy file not detected
Details
Reason
project is not fuzzed
Details
Reason
branch protection not enabled on development/release branches
Details
Reason
SAST tool is not run on all commits -- score normalized to 0
Details
Score
Last Scanned on 2025-07-07
The Open Source Security Foundation is a cross-industry collaboration to improve the security of open source software (OSS). The Scorecard provides security health metrics for open source projects.
Learn More