Quickstart: Expo
By the end of this page your app will record observations, consolidate them into facts, and read relevant memory back in a component.
-
Install the package and its peers
Terminal window npx expo install expo-sqlite expo-cryptonpm install @equationalapplications/expo-llm-wikiUse
npx expo installfor the native modules so Expo picks versions that match your SDK.expo-cryptois wired in automatically when you import the package, so you don’t need acryptopolyfill. -
Create the wiki once, at startup
src/memory.ts import * as SQLite from 'expo-sqlite';import { createWiki } from '@equationalapplications/expo-llm-wiki';export async function openMemory() {const db = await SQLite.openDatabaseAsync('app.db');const wiki = createWiki(db, {llmProvider: {// Must return the model's raw text (JSON, optionally inside a ```json fence).generateText: async ({ systemPrompt, userPrompt }) => {const res = await fetch('https://your-api.example.com/llm', {method: 'POST',headers: { 'Content-Type': 'application/json' },body: JSON.stringify({ systemPrompt, userPrompt }),});return res.text();},},});await wiki.setup(); // creates tables + runs migrations; safe to call every launchreturn wiki;} -
Provide it to your component tree
App.tsx import { useEffect, useState } from 'react';import { WikiProvider, type WikiMemory } from '@equationalapplications/expo-llm-wiki';import { openMemory } from './src/memory';import { Home } from './src/Home';export default function App() {const [wiki, setWiki] = useState<WikiMemory | null>(null);useEffect(() => { openMemory().then(setWiki); }, []);if (!wiki) return null; // or a splash screenreturn (<WikiProvider wiki={wiki}><Home /></WikiProvider>);} -
Write and read memory with hooks
src/Home.tsx import { Button, Text, View } from 'react-native';import { useMemoryRead, useWikiWrite } from '@equationalapplications/expo-llm-wiki';export function Home() {const { execute: write } = useWikiWrite();const { data, isPending, refetch } = useMemoryRead('user-123', 'hobbies');const remember = async () => {await write('user-123', {event_type: 'observation',summary: 'User mentioned they love hiking on weekends.',});refetch(); // writes don't auto-refresh readers};return (<View><Button title="Remember something" onPress={remember} />{isPending ? <Text>Loading…</Text> : data?.facts.map((f) => <Text key={f.id}>{f.title}</Text>)}</View>);}
What just happened?
Section titled “What just happened?”write()logged an event. The librarian turns events into facts when you callrunPendingMaintenance(), or automatically every 20 events if you setmaintenance: 'auto'.useMemoryRead()ran a keyword search over facts. Add anembed()function to get semantic search. See Connect your LLM provider.
Next steps
Section titled “Next steps”- How memory works: events, facts, tasks, and maintenance.
- Recipe: chat assistant with memory
- React hooks reference
- See a complete app: Curated Journal
is the open-source reference app for this package. It’s fully offline, with on-device LLMs
through
llama.rn, foreground “Night Shift” maintenance, OKF import and export, and an emergent knowledge-graph explorer.