Custom Storage
By default, the SDK uses @react-native-async-storage/async-storage for internal persistence keys.
If you prefer another storage engine, pass a custom adapter in config.storage.
Storage interface
Section titled “Storage interface”interface DetourStorage { getItem(key: string): Promise<string | null> | string | null; setItem(key: string, value: string): Promise<void> | void; removeItem?(key: string): Promise<void> | void;}Examples
Section titled “Examples”The two adapters below cover the storage engines React Native apps use most often. Any object that matches the DetourStorage interface works, so use these as starting points for other engines.
React Native MMKV
Section titled “React Native MMKV”import { createMMKV } from 'react-native-mmkv';import { DetourProvider } from '@swmansion/react-native-detour';
const storage = createMMKV();
const mmkvAdapter = { getItem: (key: string) => storage.getString(key) ?? null, setItem: (key: string, value: string) => storage.set(key, value),};
export default function App() { return ( <DetourProvider config={{ apiKey: '...', appID: '...', storage: mmkvAdapter, }} > {/* Your app */} </DetourProvider> );}Expo Secure Store
Section titled “Expo Secure Store”import * as SecureStore from 'expo-secure-store';import { DetourProvider } from '@swmansion/react-native-detour';
const secureStoreAdapter = { getItem: SecureStore.getItemAsync, setItem: SecureStore.setItemAsync,};
export default function App() { return ( <DetourProvider config={{ apiKey: '...', appID: '...', storage: secureStoreAdapter, }} > {/* Your app */} </DetourProvider> );}