A custom cache provider for SWR using MMKV storage in React Native projects.
First, install the package using your favorite package manager:
Expo
npx expo install @theafolayan/mmkv-swr-cache
Yarn
yarn add @theafolayan/mmkv-swr-cache
NPM
npm install @theafolayan/mmkv-swr-cache
Ensure you have swr and react-native-mmkv installed as well:
npx expo install swr react-native-mmkv
To use the MMKV cache provider in your React Native project, wrap your application with the SWRConfig provider, using the custom MMKVCacheProvider.
import React from 'react';
import { SWRConfig } from 'swr';
import MMKVCacheProvider from '@theafolayan/mmkv-swr-cache';
const App: React.FC = () => {
return (
<SWRConfig value={{ provider: MMKVCacheProvider }}>
<App />
</SWRConfig>
);
};
export default App;
This project is licensed under the MIT License
To show your support for this project (if you found it useful of course) please consider starring the repo and following me on Twitter (x)