Installation
Setup
Configuration
Unique identifier for the MMKV instance
Custom file path for the MMKV instance
Encryption key for encrypted storage
Usage
Basic Usage
With Custom Instance
Per-Observable MMKV Config
Plugin API
The MMKV plugin implements theObservablePersistPlugin interface:
getTable()
set()
getMetadata()
setMetadata()
deleteTable()
deleteMetadata()
Examples
Global Configuration
Encrypted Storage
Multiple MMKV Instances
App Settings
User Session
Offline-First Todo App
Clear Storage
MMKV v3 vs v4 Support
The plugin automatically detects and supports both MMKV v3 and v4:Performance
MMKV is significantly faster than AsyncStorage:| Operation | AsyncStorage | MMKV |
|---|---|---|
| Read | ~2-3ms | ~0.1ms |
| Write | ~5-10ms | ~0.2ms |
| Speedup | - | ~30x |
Encryption
MMKV supports AES-256 encryption:Storage Size
MMKV can handle large datasets efficiently:Best Practices
- Use globally: Configure MMKV once at app startup
- Encrypt sensitive data: Use encryption for credentials, tokens, etc.
- Separate instances: Use different instances for different data types
- Monitor size: MMKV is fast but still has storage limits
- Clear on logout: Remove sensitive data when user logs out
Migration from AsyncStorage
Debugging
MMKV provides helpful debugging methods:See Also
- AsyncStorage Plugin - Standard React Native storage
- synced() - Create synced observables
- configureObservableSync() - Global configuration
- react-native-mmkv - MMKV library documentation