Written in C++ with JSI
Storage functions are installed directly on the JavaScript runtime, so reads and writes are synchronous and never touch the bridge.
Built on Tencent's MMKV and JSI. Any data type, any number of databases, with or without encryption.
npm install react-native-mmkv-storagecd ios && pod installimport { MMKVLoader } from 'react-native-mmkv-storage';
const storage = new MMKVLoader().initialize();
storage.setString('user', 'ammar');
storage.setInt('age', 24);
storage.setMap('settings', { theme: 'dark' });
storage.getString('user'); // => "ammar"
storage.getMap('settings'); // => { theme: "dark" }import { MMKVLoader, useMMKVStorage } from 'react-native-mmkv-storage';
import { Text, TouchableOpacity } from 'react-native';
const storage = new MMKVLoader().initialize();
export default function Profile() {
const [user, setUser] = useMMKVStorage('user', storage, 'anonymous');
return (
<TouchableOpacity onPress={() => setUser('ammar')}>
<Text>{user}</Text>
</TouchableOpacity>
);
}Any write to user â from this component, another component, or plain non-React code â updates every hook watching that key.
import { MMKVLoader } from 'react-native-mmkv-storage';
const secure = new MMKVLoader().withInstanceID('secure').withEncryption().initialize();
secure.setString('token', 'a-secret-value');The encryption key is generated for you and stored in the Keychain or Keystore, then retrieved automatically on the next launch.
| Architecture | React Native |
|---|---|
| New architecture | 0.75+, tested up to 0.87 |
| Old architecture | 0.71+ |
Codegen specs are generated by your app at build time, so the library always compiles against the React Native version your app uses.