react-native-mmkv is a free, open source databases project written in TypeScript and released under MIT. It has 8,503 GitHub stars, 341 forks and 20 open issues, and was last pushed 4 days ago. On this registry it ranks #103 of 203 tracked projects in Databases, with 5 head-to-head comparisons available.

What is react-native-mmkv?

react-native-mmkv is an MIT-licensed TypeScript library that exposes the MMKV C++ key-value storage engine to React Native and Expo apps through direct JSI and Nitro Module bindings, and it is built for mobile developers who need fast, fully synchronous local persistence on iOS, Android and the web.

What it is

MMKV is an efficient, small mobile key-value storage framework developed by WeChat, maintained upstream at Tencent/MMKV. react-native-mmkv is the React Native binding for that engine: a library that reads and writes MMKV storage directly from JavaScript by calling into the native C++ library instead of crossing the old React Native Bridge. It lives in the React Native ecosystem, is written in TypeScript, and sits under Infrastructure & Operations / Databases. Version 4 is implemented as a Nitro Module; the previous V3 documentation is kept in README_V3.md, and the migration path is described in docs/V4_UPGRADE_GUIDE.md.

The specific thing it replaces is AsyncStorage and the asynchronous, Promise-based local persistence that comes with it. Because every call is synchronous, a value can be read during render without awaiting a Promise, without a loading state and without a Bridge round trip. The project states roughly 30x the speed of AsyncStorage, and it ships StorageBenchmark, which measures reading a value from storage 1000 times across popular storage libraries on an iPhone 11 Pro. Where plain text on disk is not acceptable, an instance can be given an encryption key, so speed and security are not an either-or choice.

Key capabilities

  • Reads and writes strings, booleans, numbers and ArrayBuffers.
  • Fully synchronous calls: no async/await, no Promises, no Bridge.
  • Encryption per instance through encryptionKey and encryptionType: 'AES-256'.
  • Multiple instances separated by id, keeping per-user storage such as user-${userId}-storage apart from the default mmkv.default.
  • Customizable storage location through path, defaulting to $(Documents)/mmkv/.
  • Built on JSI and C++ NitroModules rather than the legacy Bridge, with iOS, Android and Web support.
  • React Hooks API, plus iOS App Group sharing through an AppGroupIdentifier key in Info.plist and mode: 'multi-process'.

Who uses it and how

  • React Native teams moving hot read paths, such as session state and cached payloads, off AsyncStorage.
  • Expo projects that install with npx expo install react-native-mmkv react-native-nitro-modules and then run npx expo prebuild.
  • Apps with logged-in users that keep global app data and a user's own data in separate instances with different id values.
  • iOS apps that share storage with app extensions or other apps in the same group, using App Groups with MMKV's multi-process mode.

Getting started

Install with npm install react-native-mmkv react-native-nitro-modules and then cd ios && pod install; Expo projects instead run npx expo install react-native-mmkv react-native-nitro-modules followed by npx expo prebuild. A storage instance is created with createMMKV(), and the README recommends exporting one instance and reusing it throughout the app rather than constructing a new one each time.

How it compares

No list of paid products that this project replaces is supplied in the registry facts. Among the similar tools the facts do name, AsyncStorage is the direct counterpart and the stated point of comparison: react-native-mmkv claims roughly 30x the speed, replaces the Promise-based API with synchronous calls, and avoids the Bridge, while AsyncStorage remains the default many React Native codebases already depend on. The StorageBenchmark repository exists so that this comparison can be checked against other storage libraries directly.

When to use it — and when not to

A self-hoster here means a mobile team able to build native code: the library is a native module, so adoption requires pod install or expo prebuild and a rebuild of the app, and V4 additionally requires a migration from V3. Teams that cannot ship native builds, or that expect a managed service with server-side synchronisation, should not pick it, because MMKV stores data locally on the device and the facts show no hosted option. The documentation also shows its seams: the V4 README points readers to separate V3 docs, the upgrade guide is a distinct document, and the configuration notes for encryption and storage location are the kind that need a careful read before encryption is enabled on existing data.

project readme (upstream, from github) — read inline
V4 Docs old V3 Docs

MMKV

The fastest key/value storage for React Native.




  • MMKV is an efficient, small mobile key-value storage framework developed by WeChat. See Tencent/MMKV for more information
  • react-native-mmkv is a library that allows you to easily use MMKV inside your React Native app through fast and direct JS bindings to the native C++ library.

Features

  • Get and set strings, booleans, numbers and ArrayBuffers
  • Fully synchronous calls, no async/await, no Promises, no Bridge.
  • Encryption support (secure storage)
  • Multiple instances support (separate user-data with global data)
  • Customizable storage location
  • High performance because everything is written in C++
  • ~30x faster than AsyncStorage
  • Uses JSI and C++ NitroModules instead of the "old" Bridge
  • iOS, Android and Web support
  • Easy to use React Hooks API

[!IMPORTANT]

Benchmark

StorageBenchmark compares popular storage libraries against each other by reading a value from storage for 1000 times:

MMKV vs other storage libraries: Reading a value from Storage 1000 times.
Measured in milliseconds on an iPhone 11 Pro, lower is better.

Installation

React Native

npm install react-native-mmkv react-native-nitro-modules
cd ios && pod install

Expo

npx expo install react-native-mmkv react-native-nitro-modules
npx expo prebuild

Usage

Create a new instance

To create a new instance of the MMKV storage, use the MMKV constructor. It is recommended that you re-use this instance throughout your entire app instead of creating a new instance each time, so export the storage object.

Default
import { createMMKV } from 'react-native-mmkv'

export const storage = createMMKV()

This creates a new storage instance using the default MMKV storage ID (mmkv.default).

App Groups or Extensions

If you want to share MMKV data between your app and other apps or app extensions in the same group, open Info.plist and create an AppGroupIdentifier key with your app group's value. MMKV will then automatically store data inside the app group which can be read and written to from other apps or app extensions in the same group by making use of MMKV's multi processing mode. See Configuring App Groups.

Customize
import { createMMKV } from 'react-native-mmkv'

export const storage = createMMKV({
  id: `user-${userId}-storage`,
  path: `${USER_DIRECTORY}/storage`,
  encryptionKey: 'hunter2',
  encryptionType: 'AES-256',
  mode: 'multi-process',
  readOnly: false,
  compareBeforeSet: false,
})

This creates a new storage instance using a custom MMKV storage ID. By using a custom storage ID, your storage is separated from the default MMKV storage of your app.

The following values can be configured:

  • id: The MMKV instance's ID. If you want to use multiple instances, use different IDs. For example, you can separate the global app's storage and a logged-in user's storage. (required if path or encryptionKey fields are specified, otherwise defaults to: 'mmkv.default')
  • path: The MMKV instance's root path. By default, MMKV stores file inside $(Documents)/mmkv/. You can customize MMKV's root directory on MMKV initialization (documentation: iOS / Android)
  • encryptionKey: The MMKV instance's encryption/decryption key. By default, MMKV stores all key-values in plain text on file, relying on iOS's/Android's sandbox to make sure the file is encrypted. Should you worry about information leaking, you can choose to encrypt MMKV. (documentation: iOS / Android)
  • encryptionType: The MMKV instance's encryption/decryption algorithm. By default, AES-128 encryption will be used, but you can switch to AES-256 for advanced security.
  • mode: The MMKV's process behaviour - when set to multi-process, the MMKV instance will assume data can be changed from the outside (e.g. App Clips, Extensions or App Groups).
  • readOnly: Whether this MMKV instance should be in read-only mode. This is typically more efficient and avoids unwanted writes to the data if not needed. Any call to set(..) will throw.
  • compareBeforeSet: Whether this MMKV instance will compare values for equality before writing them to disk. By default this is disabled, enabling it might improve performance if values are repeatedly written to disk, even if they are already persisted.

Set

storage.set('user.name', 'Marc')
storage.set('user.age', 21)
storage.set('is-mmkv-fast-asf', true)

Get

const username = storage.getString('user.name') // 'Marc'
const age = storage.getNumber('user.age') // 21
const isMmkvFastAsf = storage.getBoolean('is-mmkv-fast-asf') // true

Hooks

const [username, setUsername] = useMMKVString('user.name')
const [age, setAge] = useMMKVNumber('user.age')
const [isMmkvFastAsf, setIsMmkvFastAsf] = useMMKVBoolean('is-mmkv-fast-asf')

Keys

// checking if a specific key exists
const hasUsername = storage.contains('user.name')

// getting all keys
const keys = storage.getAllKeys() // ['user.name', 'user.age', 'is-mmkv-fast-asf']

// delete a specific key + value
const wasRemoved = storage.remove('user.name')

// delete all keys
storage.clearAll()

Objects

const user = {
  username: 'Marc',
  age: 21
}

// Serialize the object into a JSON string
storage.set('user', JSON.stringify(user))

// Deserialize the JSON string into an object
const jsonUser = storage.getString('user') // '{ "username": "Marc", "age": 21 }'
const userObject = JSON.parse(jsonUser) // { username: 'Marc', age: 21 }

Encryption

// encrypt all data with a private key using AES-128
storage.encrypt('hunter2')
// encrypt all data with a private key using AES-256
storage.encrypt('hunter2again', 'AES-256')

// remove encryption
storage.decrypt()

Buffers

const buffer = new ArrayBuffer(3)
const dataWriter = new Uint8Array(buffer)
dataWriter[0] = 1
dataWriter[1] = 100
dataWriter[2] = 255
storage.set('someToken', buffer)

const buffer = storage.getBuffer('someToken')
console.log(buffer) // [1, 100, 255]

Size

// get size of MMKV storage in bytes
const size = storage.byteSize
if (size >= 4096) {
  // clean unused keys and clear memory cache
  storage.trim()
}

Importing all data from another MMKV instance

To import all keys and values from another MMKV instance, use importAllFrom(...):

const storage = createMMKV(...)
const otherStorage = createMMKV(...)

const importedCount = storage.importAllFrom(otherStorage)

Check if an MMKV instance exists

To check if an MMKV instance exists, use existsMMKV(...):

import { existsMMKV } from 'react-native-mmkv'

const exists = existsMMKV('my-instance')

Delete an MMKV instance

To delete an MMKV instance, use deleteMMKV(...):

import { deleteMMKV } from 'react-native-mmkv'

const wasDeleted = del

readme truncated — read the full docs on github

Frequently asked questions

Is react-native-mmkv free to use?

react-native-mmkv is open source under the MIT licence. There is no licence fee and no seat count — you can self-host it or, where the project offers one, pay a vendor for a managed version instead.

What does react-native-mmkv do?

⚡️ The fastest key/value storage for React Native. ~30x faster than AsyncStorage!

What is react-native-mmkv written in?

react-native-mmkv is primarily written in TypeScript. Its source is publicly available at https://github.com/margelo/react-native-mmkv, and it has 8,503 GitHub stars.