Skip to content

react-native-mmkv 3.0 is stable as a pure C++ TurboModule

updated

Version 3.0.0 of react-native-mmkv has been released as stable. V3 is a complete rewrite of the library's codebase into a pure C++ TurboModule, which the release notes say has better startup speed. iOS and Android now share a single codebase for consistency.

Bar chart of the time to read a value from storage 1,000 times, with MMKV the fastest of five storage libraries
Image: margelo/react-native-mmkv (MIT)

react-native-mmkv 3.0.0 requires react-native 0.74 or higher.

Features

  • Full rewrite to a single pure C++ / CxxTurboModule.
  • New trim() function and size property.
  • Breaking: getBuffer now uses ArrayBuffer instead of Uint8Array.
  • Breaking: errors are now properly thrown if set or recrypt fail.
  • Support for AppGroups.
  • Automocking in vitest.
  • Support for 16KB page size on newer Android phones.

Bug fixes

  • Encryption now works on keys longer than 10 characters.
  • Only C++ bindings are generated, skipping Java/ObjC.
  • The library now always calls trim, and WeakRef has been removed.
  • Only Warnings or Errors are logged in Release.
  • An error is thrown if TurboModules are not found.
  • The TurboModule is initialized eagerly because Proxies are slow.

Performance

Being a CxxTurboModule is described as faster with less initialization overhead and complexity. The memory cache is also cleared on trim and in the destructor.

Source: github.com