Local storage
Keep settings and small values across app launches with MMKV.
React state holds a draft while its screen is mounted. To reopen the same draft on the next launch, save it in an app-owned store. react-nitro-mmkv exposes synchronous MMKV storage on iOS and 64-bit Android. The store is unencrypted.
Link the module
Install react-nitro-mmkv as a direct app dependency matching your renderer version. For the starter used in the installation guide, run bun add --exact react-nitro-mmkv@0.0.1-alpha.16. The starter runs react-nitro prepare during installation to discover the module. Rebuild the native app after installation.
On iOS, the starter registers linked app modules at startup. On Android, NitroActivity initializes MMKV before it runs JavaScript. If your app hosts the Android runtime outside NitroActivity, call StorageModule.initialize(applicationContext) before evaluating JavaScript.
Save and reopen a draft
import { createMMKV } from 'react-nitro-mmkv'
const drafts = createMMKV({ id: 'drafts' })
export function saveDraft(text: string) {
drafts.set('current', text)
}
export function readDraft() {
return drafts.getString('current') ?? ''
}Open the same store ID on the next launch and pass readDraft() as a text input's defaultValue. A missing key returns undefined. Use the getter matching the stored type. The module supports strings, numbers, booleans, and ArrayBuffer values. Call drafts.remove('current') when the user discards the draft.