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
interface DetourStorage {
getItem(key: string): Promise<string | null> | string | null;
setItem(key: string, value: string): Promise<void> | void;
removeItem?(key: string): Promise<void> | void;
}
Example: 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>
);
}
Example: 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>
);
}