Skip to main content
@aomi-labs/react provides runtime logic, state management, hooks, and an API client with zero UI opinions. Use it to build completely custom interfaces or integrate Aomi logic into existing applications. Use the headless React library when you need a custom layout, branded components, or a non-chat interaction model.

Installation

Or using pnpm:

Peer Dependencies

wagmi and viem are optional peer dependencies. Install them only if your app uses wallet connection; skip them for read only or non-wallet UIs.

What’s Included

Providers

Hooks

API Client

Utilities

Types

Basic Setup

Wrap your app with AomiRuntimeProvider:
AomiRuntimeProvider internally sets up all nested providers (ThreadContext, UserContext, NotificationContext, EventContext, ControlContext), so you get the full runtime with a single wrapper.

Provider Hierarchy

AomiRuntimeProvider wraps your app with a hierarchy of context providers:
Each layer provides specific functionality through its own hook:

Runtime Provider

AomiRuntimeProvider is the top-level provider that connects your React app to the Aomi backend. It sets up all contexts needed for chat, threads, user state, notifications, and events.

Props

Typical Provider Hierarchy

In a Next.js App Router project, place AomiRuntimeProvider inside your wagmi and query providers:

Without Wallet Support

If your application does not need wallet functionality, skip the wagmi providers entirely:
The ConnectButton control and runtime transaction handler will simply be inactive.

Using AomiClient Directly

For non-React code or server-side use, you can use the AomiClient class without any providers. Construct it with an options object, not a bare URL:

When to Use Headless vs Widget

Custom UI Tutorial

Build a complete chat interface from scratch:
  1. Create a MessageList component that renders messages using useThreadContext
  2. Create a ChatInput component that sends messages via useAomiRuntime
  3. Create a ThreadSwitcher to manage multiple conversations
  4. Compose them into your page layout
The key design principle: state lives in the library, components are pure presentational.

Handler Utilities

Wallet Handler

The useWalletHandler hook processes wallet transaction and signing requests from the backend:
See the Hooks Reference for the full useWalletHandler API and result shapes.

Notification Handler

The useNotificationHandler hook processes notification events from the backend:

Event System Details

Event Types

The event context handles inbound events streamed from the backend over SSE, and lets you send outbound system messages back to the backend:

Subscription

Sending Outbound System Messages

To send a system message back to the backend, use sendOutboundSystem. It takes an object with type, sessionId, and payload:

Next Steps

Last modified on June 4, 2026