@react-native-async-storage/async-storage: key-value persistent, async API, dữ liệu lưu file (iOS) hoặc SQLite (Android). Cross-platform, ổn định, hệ sinh thái lớn. Nhược: async (Promise mỗi call) → block render khi data nhiều, plain text không mã hóa, limit ~6MB Android.
react-native-mmkv: key-value siêu nhanh, đồng bộ API, dùng MMKV của Tencent (mmap-based). 30x nhanh hơn AsyncStorage. Hỗ trợ encryption AES (option). API:
const storage = new MMKV()
storage.set('token', 'abc') // sync, không await
const token = storage.getString('token')Ưu: Sync (đọc trong render, không Promise), encryption built-in, performance đỉnh.
Expo SecureStore / react-native-keychain: dùng Keychain (iOS) / Keystore (Android) để lưu sensitive data (token, password). Mã hóa hardware-backed. Slow hơn nhiều so với MMKV vì hardware roundtrip.
Quy tắc:
- Sensitive (auth token, refresh token): SecureStore/Keychain.
- App preferences, cache nhỏ, sync cần thiết: MMKV.
- Compatibility với lib cũ, dữ liệu không sensitive: AsyncStorage.
@react-native-async-storage/async-storage: persistent key-value, async API, stored as a file (iOS) or SQLite (Android). Cross-platform, stable, large ecosystem. Downsides: async (Promise per call) blocks rendering with lots of data, plain text — no encryption, ~6 MB Android limit.
react-native-mmkv: extremely fast key-value with a synchronous API, backed by Tencent's MMKV (mmap-based). 30x faster than AsyncStorage. Optional AES encryption.
const storage = new MMKV()
storage.set('token', 'abc') // sync, no await
const token = storage.getString('token')Pros: sync (readable inside render), built-in encryption, top performance.
Expo SecureStore / react-native-keychain: stores sensitive data (tokens, passwords) in the Keychain (iOS) / Keystore (Android), with hardware-backed encryption. Slower than MMKV due to the hardware roundtrip.
Rule:
- Sensitive data (auth/refresh tokens): SecureStore/Keychain.
- App preferences, small cache, sync required: MMKV.
- Compatibility with older libs, non-sensitive data: AsyncStorage.