⚡️ The fastest key/value storage for React Native. ~30x faster than AsyncStorage!
fastWrites
prop2.7.0 adds a new prop to the MMKV configuration that changes the behaviour of set
calls.
fastWrites
is set to true
, MMKV does not overwrite previous values when calling set
. This is faster, but uses more memory.fastWrites
is set to false
, MMKV deletes the previous value before calling set
. This makes sure the storage size is always as small as possible, with the added performance cost of one delete call before setting.Before this version, MMKV behaved as if fastWrites
was set to true
(i.e.; fast, but use more memory). Now after this PR, fastWrites
is false
by default, because users were complaining in #440 that the storage size grows too big.
Starting from 2.6.0., react-native-mmkv only works on react-native 0.71 and above.
If you use react-native 0.70 and below, you should use react-native-mmkv 2.5.1.
Starting from 2.6.0., react-native-mmkv only works on react-native 0.71 and above.
If you use react-native 0.70 and below, you should use react-native-mmkv 2.5.1.
Example:
const storage = new MMKV()
// Set to storage
const buffer = new Uint8Array([255, 100, 8, 5])
storage.set('someToken', buffer)
// Get from storage
const buffer = storage.getBuffer('someToken')
console.log(buffer) // [255, 100, 8, 5]
// Fun Fact:
// You can read every value as a Buffer:
storage.set('someString', 'Hey!');
const buffer = storage.getBuffer('someString')
console.log(buffer); // [72, 101, 121, 33]