Overview
React Native hooks for building AI-powered mobile applications.
The @reverbia/sdk/expo package provides React hooks optimized for
Expo and React Native environments. These hooks exclude web-only
dependencies (like pdfjs-dist) that aren’t compatible with React Native.
Installation & Setup
Before using this package, you must set up polyfills for React Native compatibility. See the polyfills module documentation for complete setup instructions.
Quick setup summary:
pnpm install @reverbia/sdk@next web-streams-polyfill react-native-get-random-values @ethersproject/shims bufferThen create an entrypoint file with all required polyfills. See ai-example-expo for a complete working example.
Differences from React Package
The Expo package is a lightweight subset of @reverbia/sdk/react:
- No PDF text extraction (pdfjs-dist is web-only)
- Uses XMLHttpRequest for streaming (fetch streaming isn’t supported in RN)
Authentication
Use @privy-io/expo for authentication in React Native:
import { PrivyProvider, usePrivy } from "@privy-io/expo";
import { useIdentityToken } from "@privy-io/expo";
// Wrap your app with PrivyProvider
<PrivyProvider appId="your-app-id" clientId="your-client-id">
<App />
</PrivyProvider>;
// Get identity token for API calls
const { getIdentityToken } = useIdentityToken();Quick Start
import { useIdentityToken } from "@privy-io/expo";
import { useChat } from "@reverbia/sdk/expo";
function ChatScreen() {
const { getIdentityToken } = useIdentityToken();
const { isLoading, sendMessage, stop } = useChat({
getToken: getIdentityToken,
baseUrl: "https://portal.anuma-dev.ai",
onData: (chunk) => {
// Handle streaming chunks
const content =
typeof chunk === "string"
? chunk
: chunk.choices?.[0]?.delta?.content || "";
console.log("Received:", content);
},
onFinish: () => console.log("Stream finished"),
onError: (error) => console.error("Error:", error),
});
const handleSend = async () => {
await sendMessage({
messages: [{ role: "user", content: [{ type: "text", text: "Hello!" }] }],
model: "openai/gpt-4o",
});
};
return (
<View>
<Button onPress={handleSend} disabled={isLoading} title="Send" />
{isLoading && <Button onPress={stop} title="Stop" />}
</View>
);
}Hooks
| Function | Description |
|---|---|
| useChat | A React hook for managing chat completions with authentication. |
| useChatStorage | A React hook that wraps useChat with automatic message persistence using WatermelonDB. |
| useMemoryStorage | A React hook that wraps useMemory with automatic memory persistence using WatermelonDB. |
Other
CachedServerTools
Re-exports CachedServerTools
ChatConversation
Re-exports ChatConversation
ChatMessage
Re-exports ChatMessage
ChatRole
Re-exports ChatRole
chatStorageMigrations
Re-exports chatStorageMigrations
chatStorageSchema
Re-exports chatStorageSchema
clearAllEncryptionKeys
Re-exports clearAllEncryptionKeys
clearEncryptionKey
Re-exports clearEncryptionKey
clearServerToolsCache
Re-exports clearServerToolsCache
CreateConversationOptions
Re-exports CreateConversationOptions
CreateMemoryOptions
Re-exports CreateMemoryOptions
createMemoryRetrievalTool
Re-exports createMemoryRetrievalTool
CreateMessageOptions
Re-exports CreateMessageOptions
DatabaseManager
Re-exports DatabaseManager
DatabaseManagerLogger
Re-exports DatabaseManagerLogger
DatabaseManagerOptions
Re-exports DatabaseManagerOptions
DEFAULT_CACHE_EXPIRATION_MS
Re-exports DEFAULT_CACHE_EXPIRATION_MS
embedAllMessages
Re-exports embedAllMessages
EmbeddedWalletSignerFn
Re-exports EmbeddedWalletSignerFn
embedMessage
Re-exports embedMessage
FileMetadata
Re-exports FileMetadata
FlushResult
Re-exports FlushResult
generateCompositeKey
Re-exports generateCompositeKey
generateConversationId
Re-exports generateConversationId
generateEmbedding
Re-exports generateEmbedding
generateEmbeddings
Re-exports generateEmbeddings
generateUniqueKey
Re-exports generateUniqueKey
getCachedServerTools
Re-exports getCachedServerTools
getServerTools
Re-exports getServerTools
hasEncryptionKey
Re-exports hasEncryptionKey
MemoryItem
Re-exports MemoryItem
MemoryRetrievalEmbeddingOptions
Re-exports MemoryRetrievalEmbeddingOptions
MemoryRetrievalResult
Re-exports MemoryRetrievalResult
MemoryRetrievalSearchOptions
Re-exports MemoryRetrievalSearchOptions
memoryStorageSchema
Re-exports memoryStorageSchema
MemoryType
Re-exports MemoryType
onKeyAvailable
Re-exports onKeyAvailable
PlatformStorage
Re-exports PlatformStorage
queueManager
Re-exports queueManager
QueueManager
Re-exports QueueManager
QueueStatus
Re-exports QueueStatus
requestEncryptionKey
Re-exports requestEncryptionKey
SDK_SCHEMA_VERSION
Re-exports SDK_SCHEMA_VERSION
sdkMigrations
Re-exports sdkMigrations
sdkModelClasses
Re-exports sdkModelClasses
sdkSchema
Re-exports sdkSchema
SearchSource
Re-exports SearchSource
ServerToolsOptions
Re-exports ServerToolsOptions
ServerToolsResponse
Re-exports ServerToolsResponse
SignMessageFn
Re-exports SignMessageFn
StoredChatCompletionUsage
Re-exports StoredChatCompletionUsage
StoredConversation
Re-exports StoredConversation
StoredMemory
Re-exports StoredMemory
StoredMemoryModel
Re-exports StoredMemoryModel
StoredMemoryWithSimilarity
Re-exports StoredMemoryWithSimilarity
StoredMessage
Re-exports StoredMessage
StoredMessageWithSimilarity
Re-exports StoredMessageWithSimilarity
UpdateMemoryOptions
Re-exports UpdateMemoryOptions
useCredits
Re-exports useCredits
UseCreditsOptions
Re-exports UseCreditsOptions
UseCreditsResult
Re-exports UseCreditsResult
useEncryption
Re-exports useEncryption
useModels
Re-exports useModels
UseModelsResult
Re-exports UseModelsResult
WalletPoller
Re-exports WalletPoller