React
Embed ChatAI with the @nightzeros/chatai-react ChatWidget component.
Install from npm:
pnpm add @nightzeros/chatai-reactUse 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",
}}
/>experience | Layout |
|---|---|
classic | Mic in composer + waveform (default) |
orb | Full voice stage inside the chat panel |
dock | Talk control + compact card beside the launcher |
guided | Welcome + suggested questions, then stage |
companion | Character stage with assistant name / welcome |
side-panel | Tall 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
| Prop | Type | Notes |
|---|---|---|
assistantId | string | Required — publicId |
apiUrl | string | Required — ChatAI origin |
className | string | Optional wrapper class |
theme | "light" | "dark" | "system" | Optional |
primaryColor | string | Optional |
position | "bottom-left" | "bottom-right" | Optional |
iconUrl | string | null | Optional |
suggestedQuestions | string[] | Optional |
showSources | boolean | Optional |
layout | "fixed" | "contained" | Optional |
voice | boolean | Optional — 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 / onError | callbacks | Optional |
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 devSee Examples.
Related
- Widget — script tag path
- Voice (preview)
- Upgrading to 1.4
- Assistants