Local Storage
Persist data with AsyncStorage, SQLite, MMKV, and secure storage for tokens.
AsyncStorage
AsyncStorage stores string key-value pairs asynchronously. Serialize objects with JSON.stringify. Suitable for preferences and small caches.
Operations are async—await setItem and getItem. MultiGet batches reads for startup hydration.
Not encrypted—do not store refresh tokens or PII without encryption layer.
- Namespace keys: @app/settings/theme
- Handle null when key missing
- Migrate schema versions on app upgrade
import AsyncStorage from '@react-native-async-storage/async-storage';
await AsyncStorage.setItem('theme', 'dark');
const theme = await AsyncStorage.getItem('theme');SQLite and MMKV
expo-sqlite or react-native-quick-sqlite store relational offline data: carts, message history, draft forms. Migrate schemas with versioned PRAGMA user_version.
MMKV offers synchronous fast key-value for performance-critical reads. react-native-keychain stores credentials in secure enclave.
Choose storage by access pattern: MMKV for flags, SQLite for queryable offline datasets.
- Encrypt sensitive SQLite columns at app level if needed
- Batch writes in transactions for consistency
- Cap cache size to avoid unbounded disk growth