Skip to content

API Reference

The ChatWidget component is the main entry point to add chat functionality to your site.

ChatWidget Props

Below is the list of props accepted by the ChatWidget component. All are optional except if you want real API connectivity (require apiUrl).

PropTypeDefaultDescription
apiUrlstringBase URL of your chat API.
apiTokenstringBearer token for API authentication. Provide via environment variables.
position"bottom-right" | "bottom-left" | "bottom-center""bottom-right"Where the widget appears on screen.
theme"dark" | "light""dark"Color theme preset.
colorsChatColorsCustom color overrides for primary, background, text, border, userbubble, and surface.
labelsChatLabelsCustom text for TECHNICAL indicators (assistant tags, latency text, etc.).
persistenceKeystring"ask_widget_session"localStorage key for history persistence.
titlestring"Ask AI"Title shown in the chat panel header.
placeholderstring"Ask me anything..."Placeholder text in the message input.
initialMessagestring"Hello! How can I help you today?"First message displayed when the panel opens.
defaultOpenbooleanfalseWhether the chat panel starts open.
streamResponseChatStreamHandlerCustom response handler — takes full control of streaming.

ChatStreamHandler Type

If you have a non-standard API or require custom fetch logic, you can pass a streamResponse handler:

ts
export type ChatStreamResult =
  | string
  | AsyncIterable<string>
  | Promise<string | AsyncIterable<string>>

export type ChatStreamHandler = (
  message: string, 
  history: ChatMessage[]
) => ChatStreamResult

Example Usage:

tsx
const streamResponse: ChatStreamHandler = async function* (message, history) {
  const res = await fetch('/api/chat', { 
    method: 'POST', 
    body: JSON.stringify({ message, history }) 
  })
  
  if (!res.ok) throw new Error('API request failed')
  
  const reader = res.body!.getReader()
  // decode and yield tokens...
}

<ChatWidget streamResponse={streamResponse} />

Released under the MIT License.