ChatAI Docs

React

Embed ChatAI with the @nightzeros/chatai-react ChatWidget component.

Install from npm:

pnpm add @nightzeros/chatai-react

Use 1.4.0 or later for Voice experiences (Orb, Dock, Guided, Companion, Side panel). Voice itself (playback gate) needs 1.2.0+. Peer dependency: React 18 or 19. The package entry includes "use client" for Next.js App Router.

Inside this monorepo during development, use workspace:* instead of the public registry.

{
  "dependencies": {
    "@nightzeros/chatai-react": "workspace:*"
  }
}

Basic usage

"use client";

import { ChatWidget } from "@nightzeros/chatai-react";

export function SupportChat() {
  return (
    <ChatWidget
      assistantId="asst_your_public_id"
      apiUrl="https://app.nightzeros.com"
    />
  );
}

apiUrl must be the absolute ChatAI origin (same as BETTER_AUTH_URL / widget API host). Appearance and Voice experience normally come from the assistant’s saved Customize settings.

Voice appearance

Optional mount-level override (does not remount an active Voice session when only presentation changes):

<ChatWidget
  assistantId="asst_your_public_id"
  apiUrl="https://app.nightzeros.com"
  voiceAppearance={{
    experience: "orb",
    captionsDefault: true,
    motion: "system",
  }}
/>
experienceLayout
classicMic in composer + waveform (default)
orbFull voice stage inside the chat panel
dockTalk control + compact card beside the launcher
guidedWelcome + suggested questions, then stage
companionCharacter stage with assistant name / welcome
side-panelTall edge sheet beside the page

Prefer saving the experience in Customize so every embed stays consistent. Hide Voice on a page with voice={false}. Full setup: Voice (preview). Upgrade from 1.3: Upgrading to 1.4.

Props

PropTypeNotes
assistantIdstringRequired — publicId
apiUrlstringRequired — ChatAI origin
classNamestringOptional wrapper class
theme"light" | "dark" | "system"Optional
primaryColorstringOptional
position"bottom-left" | "bottom-right"Optional
iconUrlstring | nullOptional
suggestedQuestionsstring[]Optional
showSourcesbooleanOptional
layout"fixed" | "contained"Optional
voicebooleanOptional — false hides the Voice button even when the assistant offers Voice. Voice requires 1.2.0+ (Voice (preview))
voiceAppearance{ experience?: "classic" | "orb" | "dock" | "guided" | "companion" | "side-panel"; accentColor?: string; captionsDefault?: boolean; motion?: "system" | "reduced" }Optional — overrides Customize for this mount (1.4.0+). See Widget.
onReady / onErrorcallbacksOptional

Low-level: mountChatWidget(element, options) from the same package.

Example app

# examples/react-widget/.env
VITE_CHATAI_ORIGIN=http://localhost:3000
VITE_CHATAI_ASSISTANT_ID=asst_your_public_id

pnpm --filter @chatai/example-react-widget dev

See Examples.