Skip to Content
Anuma SDKReactOverview

Overview

The @anuma/sdk/react package provides a collection of React hooks designed to simplify building AI features in your applications. These hooks abstract away the complexity of managing streaming responses, loading states, authentication, and real-time updates, letting you focus on creating great user experiences.

Why Use These Hooks?

Building AI-powered interfaces involves handling many concerns: streaming responses token-by-token, managing conversation state, coordinating tool execution, processing file attachments, and more. These hooks provide production-ready abstractions that handle these complexities out of the box.

Key benefits:

  • Streaming-first: Built-in support for real-time streaming with automatic UI updates as content arrives
  • State management: Automatic handling of loading states, errors, and request lifecycle
  • File processing: Extract text from PDFs and images (OCR) to provide document context to your AI
  • Memory & context: Extract and retrieve relevant memories using semantic search to make your AI context-aware
  • Wallet-based encryption: Secure data encryption using wallet signatures for Web3 applications

Quick Start

import { useChat } from "@anuma/sdk/react"; function ChatComponent() { const { isLoading, sendMessage, stop } = useChat({ getToken: async () => getAuthToken(), onData: (chunk) => setResponse((prev) => prev + chunk), }); const handleSend = async () => { await sendMessage({ messages: [{ role: "user", content: [{ type: "text", text: input }] }], model: "fireworks/accounts/fireworks/models/kimi-k2p5", }); }; return ( <div> <button onClick={handleSend} disabled={isLoading}>Send</button> {isLoading && <button onClick={stop}>Stop</button>} </div> ); }

Encryption

FunctionDescription
decryptDataDecrypts data using AES-GCM with the stored encryption key.
decryptDataBatchBatch decrypt multiple values efficiently with a single key lookup. Much faster than calling decryptData for each value individually.
decryptDataBytesFromBytesLike decryptDataBytes but takes the raw encrypted bytes ([IV][ciphertext+tag]) directly instead of a hex string. Skips the hexToBytes conversion — for large binary media the hex string the caller would otherwise build is a ~1.37x copy of the whole payload (a ~1GB string for a 500MB video), plus this avoids a second byte copy. Same key resolution as decryptDataBytes.
deriveKeyFromSignatureBytesDerives the bytes-native AES key from a raw signature.
encryptDataEncrypts data using AES-GCM with the stored encryption key.
encryptDataBatchBatch encrypt multiple values efficiently with a single key lookup. Much faster than calling encryptData for each value individually.
encryptDataBytesLike encryptData but takes raw bytes and returns the raw encrypted [IV][ciphertext+tag] Uint8Array instead of a hex string. Avoids the hex round-trip (encryptData returns hex, which callers immediately convert back to bytes) — for large binary media that hex string is a ~1.37x copy of the whole payload. Use for binary uploads (e.g. enc:v3 media frames).

Hooks

NameDescription
UseEncryptionResultResult returned by the useEncryption hook.
UseExportPdfResultResult returned by the useExportPdf hook.
UseOCRResultResult returned by the useOCR hook.
UsePdfResultResult returned by the usePdf hook.
UseVoiceOptionsOptions for the useVoice hook.
UseVoiceResultResult returned by the useVoice hook.
useBackupUnified React hook for backup and restore functionality.
useBackupAuthHook to access unified backup authentication state and methods.
useChatA React hook for managing chat completions with authentication.
useChatStorageA React hook that wraps useChat and persists messages and conversations to WatermelonDB as they are sent and received.
useCreditsReact hook for managing credits: checking balance, browsing packs, and purchasing credits.
useEncryptionHook that provides encryption key management for securing local data.
useExportPdfReact hook for exporting content as PDF.
useFilesA React hook for managing files (images, videos, audio, documents).
useICloudAuthHook to access iCloud authentication state and methods.
useICloudBackupReact hook for iCloud backup and restore functionality.
useModelsReact hook for fetching available LLM models. Automatically fetches all available models.
useOCRReact hook for extracting text from images using OCR.
usePdfReact hook for extracting text from PDF files.
usePhoneCallsReact hook for phone calling: checking availability, creating calls, fetching their status, and polling for completion.
useProjectsA React hook for managing projects (conversation groups).
useSettingsA React hook for managing user settings with automatic persistence using WatermelonDB.
useSubscriptionReact hook for managing subscription status and billing operations. Provides methods to check status, upgrade, manage billing, cancel, and renew subscriptions.
useToolsReact hook for fetching and caching server-side tools.
useVoiceReact hook for recording voice and transcribing it on-device using Whisper.
useWalletBindingReact hook for managing ZETA wallet bindings and reading staked-based Pro status. Provides methods to list bound wallets, request a binding nonce, bind a wallet with a signed proof, and unbind a wallet.

Other

DEFAULT_ICLOUD_BACKUP_FOLDER

Renames and re-exports BACKUP_ICLOUD_FOLDER

PDF Export

NameDescription
PdfExportOptionsOptions for PDF export.
PdfExportProgressProgress event emitted during PDF export.
PdfExportStageStages of the PDF export pipeline.
exportElementToPdfCapture a rendered HTML element as a high-fidelity PDF.
exportMarkdownToPdfConvert a markdown string to a PDF. No DOM required.
renderElementToCanvasRender a DOM element to a canvas using iframe isolation.
Last updated on