@instantdb/expo-sqlite
v1.0.52
Published
Expo SQLite interface for Instant DB
Readme
Welcome to Instant's Expo SQLite interface.
Usage
Create an app with expo
npx create-expo-app instant-rn-demo
cd instant-rn-demoInstall instant
npm i @instantdb/react-native @instantdb/expo-sqliteInstall peer dependencies
npx expo install expo-sqlite @react-native-community/netinfo react-native-get-random-values @react-native-async-storage/async-storageImport Storage from @instantdb/expo-sqlite
// ༼ つ ◕_◕ ༽つ Real-time Chat
// ----------------------------------
// * Updates instantly
// * Multiplayer
// * Works offline
import { init, id } from '@instantdb/react-native';
import SQLiteStore from '@instantdb/expo-sqlite';
const db = init({
appId: process.env.EXPO_PUBLIC_INSTANT_APP_ID,
Store: SQLiteStore,
});
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 Discord
