UIHeadless

Headless Library

@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.

Installation

npm install @aomi-labs/react

What's Included

Providers

ExportDescription
AomiRuntimeProviderTop-level provider that connects to the Aomi backend and sets up all contexts
ThreadContextProviderThread state management (messages, metadata, thread switching)
ExtUserProviderWallet/user state (address, chain, connection status)
NotificationContextProviderToast notification state
EventContextProviderSSE subscription and system event dispatch
ControlContextProviderModel/app/API key selection state

Hooks

HookDescription
useAomiRuntimeUnified API combining all sub-contexts (threads, messages, user, events, notifications, wallet)
useUserWallet/user state and setters
useThreadContextCurrent thread ID, messages map, metadata map
useCurrentThreadMessagesMessages for the active thread
useCurrentThreadMetadataMetadata (title, status) for the active thread
useControlModel/app/API key state and selection
useNotificationShow, dismiss, and list notifications
useEventContextSSE subscription and outbound event dispatch
useWalletHandlerHandle wallet transaction and signing requests
useNotificationHandlerProcess notification events from the backend

API Client

ExportDescription
BackendApiDirect HTTP client for the Aomi backend (usable outside React)

Utilities

ExportDescription
cnClass name merger (clsx + tailwind-merge)
formatAddressTruncates wallet addresses for display (0xABC...12)
getNetworkNameResolves chain ID to human-readable network name
getChainInfoReturns chain metadata (name, ticker, explorer URL)
SUPPORTED_CHAINSArray of supported chain configurations

Types

import type {
  AomiRuntimeApi,
  AomiMessage,
  ThreadMetadata,
  ThreadControlState,
  UserState,
  ControlState,
  Notification,
  NotificationType,
  WalletRequest,
  WalletTxPayload,
  WalletEip712Payload,
  InboundEvent,
  OutboundEvent,
  SSEStatus,
} from "@aomi-labs/react";

Peer Dependencies

{
  "@assistant-ui/react": "^0.11.0",
  "react": "^18.0.0 || ^19.0.0",
  "react-dom": "^18.0.0 || ^19.0.0"
}

Basic Setup

Wrap your app with AomiRuntimeProvider:

import { AomiRuntimeProvider } from "@aomi-labs/react";

function App() {
  return (
    <AomiRuntimeProvider backendUrl="https://api.aomi.dev">
      <YourCustomUI />
    </AomiRuntimeProvider>
  );
}

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

When to Use Headless vs Widget

ScenarioRecommendation
Standard chat interface needed quicklyWidget
Existing design system, custom lookHeadless
Non-Next.js React appHeadless
Server-side API calls (no React)Headless (BackendApi class directly)
Want to start fast, customize laterWidget (edit source files)
Embedding in an existing complex layoutHeadless

Next Steps

On this page