Skip to main content

Install

Import from the React sub-package:
During development, issue an hk_test_ credential from the admin panel instead of a live hk_live_ one. Sandbox is a property of the credential, not a different base URL — you call the same https://api.humain.ai host either way. Sandbox sessions don’t consume production LLM credits and aren’t billed. See Sandbox mode.

Usage

The <KioskChat> component renders a fully-featured chat UI in a single line. Drop it anywhere in your component tree.

<KioskChat> props

string
required
Device credential token, hk_live_… (production) or hk_test_… (sandbox — see Sandbox mode). Pass via an environment variable — never hardcode in production client bundles.
string
default:"\"Type a message…\""
Input field placeholder text.
string
Message shown in the chat window on first render before the user types anything.
string
CSS class applied to the outermost container — use for sizing and layout.
(message: string) => void
Called each time the user submits a message.
(response: string) => void
Called each time the AI returns a complete response.
(error: KioskError) => void
Called on any API or network error. The component shows a generic error state by default.

Advanced topics

Both <KioskChat> and <KioskVoice> are client components — they use browser APIs (WebSocket, WebRTC, navigator.mediaDevices) and cannot run during SSR.Add "use client" to any file that imports them:
Do not instantiate HumainKioskClient at module scope in a Server Component — the client constructor accesses window and will throw during server render. Instantiate it inside a useEffect or inside a Client Component.For credentials in Next.js, use NEXT_PUBLIC_HUMAIN_CREDENTIAL for client-side usage (sandbox only) or proxy calls through an API route to keep live credentials server-side.
If your app navigates between pages without a full page reload (SPA routing), call closeSession() in a cleanup function to avoid leaking sessions:
useKioskSession also auto-closes the session when the component unmounts if autoOpen is enabled.
Never expose live credentials in client-side code. Your hk_live_… token is a long-lived secret. In browser environments, either proxy API calls through your own server or issue an hk_test_… (sandbox) credential instead for public-facing demos. Treat it like a password.