Guides
Storage
Storage guide with the react-native-mmkv library.
Caracal ships with a simple storage module built on react-native-mmkv, a fast key-value store for React Native. A thin utility wrapper lives at src/lib/storage.tsx to keep usage ergonomic and type-safe across the codebase.
Storage Utilities
The wrapper at src/lib/storage.tsx exports three helpers:
getItem<T>(key)— reads and JSON-deserializes a value; returnsnullif absentsetItem<T>(key, value)— JSON-serializes and writes a valueremoveItem(key)— deletes a key
The shared instance is created with createMMKV() and uses the default unencrypted storage. The helpers persist the demo session and accounts. Preference hooks also use MMKV directly.
Keys used by the starter
| Key | Written by | Contents |
|---|---|---|
accounts | src/lib/auth/accounts.ts | Local accounts: id, full name, email, salt and password hash |
session | src/lib/auth/utils.tsx | { userId } of the signed-in account |
IS_FIRST_TIME | useIsFirstTime() | Whether onboarding was completed |
SELECTED_THEME | useSelectedTheme() | light, dark or system |
local | useSelectedLanguage() | en or vi |
Passwords are only ever stored as a salted SHA-256 hash, never in plain text.
Why MMKV?
- Synchronous: No
async/awaitneeded — reads and writes are instant - Hook support:
react-native-mmkvexposes reactive hooks for live value subscriptions
See the official MMKV docs for encryption setup, hooks, and advanced configuration.