Skip to main content
ExpoBetaOffline-first

React Native / Expo SDK

Built for mobile-first AI applications with offline support via SQLite. Integrates with ImpossibleAI for local LLM inference. Works with Expo SDK 50+.

ImpossibleAI integration
When combined with ImpossibleAI, the Expo SDK runs the full 13-stage pipeline on-device with no network required. See the ImpossibleAI docs for device requirements and model selection.

Installation

bash
npx expo install truenorth-expo expo-sqlite

Initialize

typescript/lib/truenorth.ts
import { TrueNorthMobile } from "truenorth-expo";
export const engine = new TrueNorthMobile({
provider: "ollama", // "ollama" | "openai" | "gemini"
model: "llama3.1", // local model via ImpossibleAI
offlineMode: {
enabled: true,
storage: "sqlite",
syncOnReconnect: true,
},
compliance: ["dpdp"],
});

useTrueNorth Hook

typescript/screens/ChatScreen.tsx
import { useTrueNorth } from "truenorth-expo";
export function ChatScreen() {
const {
messages, send,
output, isTyping, isComplete,
isOnline, costUsd,
} = useTrueNorth({
yamlPath: "agents/medical_intake.yaml",
sessionId: "user_priya_intake_001",
});
return (
<View style={styles.container}>
<FlatList
data={messages}
renderItem={({ item }) => (
<MessageBubble text={item.text} isAgent={item.role === "agent"} />
)}
/>
{isTyping && <TypingIndicator />}
{!isComplete && (
<TextInput
onSubmitEditing={e => send(e.nativeEvent.text)}
placeholder="Type a message…"
/>
)}
{isComplete && <OutputCard data={output} />}
{!isOnline && <OfflineBadge />}
</View>
);
}

Offline Sync

typescript
import { useSyncStatus, useTrueNorth } from "truenorth-expo";
function SyncStatus() {
const { pendingSessions, isSyncing } = useSyncStatus();
const { triggerSync } = useTrueNorth();
// TrueNorth syncs automatically when connectivity returns.
// Call triggerSync() to force a manual sync.
return (
<View>
{pendingSessions > 0 && (
<Text>{pendingSessions} sessions waiting to sync</Text>
)}
{isSyncing && <ActivityIndicator />}
</View>
);
}

Expo-specific Notes

  • SQLite sessions persist across app restarts automatically — no extra setup needed
  • Background sync uses Expo Background Fetch — add the permission in app.json
  • For camera / photo inputs, use the built-in expo-camera integration in YAML
  • Push notification reminders use Expo Notifications — configure in truenorth.config.ts
  • New Architecture (JSI) supported from truenorth-expo@0.1.3+