MMKVStorageAdapter
Fast, encrypted storage adapter using react-native-mmkv.
The MMKVStorageAdapter uses MMKV for high-performance, encrypted storage. Recommended for most apps.
Installation
npm install react-native-mmkv
# or
bun add react-native-mmkvFor iOS, run pod install:
cd ios && pod installUsage
import { TeardownCore } from '@teardown/react-native';
import { ExpoDeviceAdapter } from '@teardown/react-native/adapters/expo';
import { MMKVStorageAdapter } from '@teardown/react-native/adapters/mmkv';
export const teardown = new TeardownCore({
org_id: 'your-org-id',
project_id: 'your-project-id',
api_key: 'your-api-key',
storageAdapter: new MMKVStorageAdapter(),
deviceAdapter: new ExpoDeviceAdapter(),
});Import Path
import { MMKVStorageAdapter } from '@teardown/react-native/adapters/mmkv';Benefits
- Synchronous - No async/await needed for reads/writes
- Encrypted - Data encrypted by default
- Fast - Memory-mapped for optimal performance
- Small - Minimal bundle size impact
- Reliable - Used by WeChat with 1B+ users
How It Works
MMKV uses memory-mapped files for storage:
- Data is written to memory
- OS flushes to disk asynchronously
- Reads are instant (from memory)
- Crash-safe with journaling
Requirements
react-native-mmkv>= 2.0.0- React Native >= 0.71
Platform Notes
iOS
- Requires
pod install - Data stored in app's sandboxed Documents directory
- Encrypted with iOS Keychain
Android
- Works out of the box
- Data stored in app's private directory
- Encrypted with Android KeyStore
Expo Compatibility
For Expo managed workflow, you need a development build:
npx expo install react-native-mmkv
npx expo prebuildOr use EAS Build for production.