Skip to content

Storage

Storage

The starter comes with a simple storage module that uses react-native-mmkv to store data in a key-value format. We also added a simple storage utility to assist you in using the storage module.

src/core/storage.tsx
import { MMKV } from 'react-native-mmkv';
export const storage = new MMKV();
export function getItem<T>(key: string): T {
const value = storage.getString(key);
return value ? JSON.parse(value) || null : null;
}
export async function setItem<T>(key: string, value: T) {
storage.set(key, JSON.stringify(value));
}
export async function removeItem(key: string) {
storage.delete(key);
}

The react-native-mmkv library provides various features such as using hooks and adding encryption to stored data. Feel free to check the official docs for more information.