@interface-db/react-native-mmkv
v1.0.67
Published
React Native MMKV interface for InterfaceDB
Readme
@interface-db/react-native-mmkv
React Native MMKV interface for InterfaceDB.
Maintained by InterfaceDB, based on the Instant source. See LICENSE.md and NOTICE for attribution.
Welcome to InterfaceDB’s React Native MMKV interface.
Usage
Create an app with expo
npx create-expo-app instant-rn-demo
cd instant-rn-demoInstall instant
npm i @interface-db/react-native @interface-db/react-native-mmkvInstall peer dependencies
npx expo install react-native-mmkv react-native-nitro-modules @react-native-community/netinfo react-native-get-random-valuesPrebuild
npx expo prebuildImport Storage from @interface-db/react-native-mmkv
// ༼ つ ◕_◕ ༽つ Real-time Chat
// ----------------------------------
// * Updates instantly
// * Multiplayer
// * Works offline
import { init, id } from '@interface-db/react-native';
import MMKVStore from '@interface-db/react-native-mmkv';
const db = init({
appId: process.env.EXPO_PUBLIC_INSTANT_APP_ID,
Store: MMKVStore,
});
function Chat() {
// 1. Read
const { isLoading, error, data } = db.useQuery({
messages: {},
});
// 2. Write
const addMessage = (message) => {
db.transact(db.tx.messages[id()].update(message));
};
// 3. Render!
return <UI data={data} onAdd={addMessage} />;
}Get Started
Follow the getting started tutorial to set up a live React Native app in under 5 minutes!
Questions?
If you have any questions, feel free to drop us a line on our issue tracker
