
Research
2025 Report: Destructive Malware in Open Source Packages
Destructive malware is rising across open source registries, using delays and kill switches to wipe code, break builds, and disrupt CI/CD.
react-native-mmkv-storage
Advanced tools
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
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.
import { MMKVLoader, useMMKVStorage } from 'react-native-mmkv-storage';
const storage = new MMKVLoader().initialize();
const App = () => {
const [user, setUser] = useMMKVStorage('user', storage, 'robert');
const [age, setAge] = useMMKVStorage('age', storage, 24);
return (
<View style={styles.header}>
<Text style={styles.headerText}>
I am {user} and I am {age} years old.
</Text>
</View>
);
};
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.
const App = () => {
// Get list of all post ids
const postsIndex = useMMKVStorage("postsIndex",storage,[]); // ['post123','post234'];
// Get the posts based on those ids.
const [posts,update,remove] = useIndex(postsIndex,"object" storage);
return <View>
<FlatList
data={posts}
renderItem={...}
>
</View>
}
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.
MMKV.transactions.register('object', 'beforewrite', ({ key, value }) => {
if (key.startsWith('post.')) {
// Call this only when the key has the post prefix.
let indexForTag = MMKV.getArray(`${value.tag}-index`) || [];
MMKV.setArray(indexForTag.push(key));
}
});
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.
const userStorage = new MMKVLoader().withEncryption().withInstanceID('userdata').initialize();
const 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:
const storage = new MMKVLoader()
.withEncryption() // Generates a random key and stores it securely in Keychain
.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)
FAQs
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
The npm package react-native-mmkv-storage receives a total of 5,791 weekly downloads. As such, react-native-mmkv-storage popularity was classified as popular.
We found that react-native-mmkv-storage demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Research
Destructive malware is rising across open source registries, using delays and kill switches to wipe code, break builds, and disrupt CI/CD.

Security News
Socket CTO Ahmad Nassri shares practical AI coding techniques, tools, and team workflows, plus what still feels noisy and why shipping remains human-led.

Research
/Security News
A five-month operation turned 27 npm packages into durable hosting for browser-run lures that mimic document-sharing portals and Microsoft sign-in, targeting 25 organizations across manufacturing, industrial automation, plastics, and healthcare for credential theft.