Skip to content

Widget API

This content is for v1.x. Switch to the latest version for up-to-date documentation.

import { ChatWidget } from "claudius-chat-widget";
import "claudius-chat-widget/style.css";
interface ChatWidgetProps {
apiUrl: string;
title?: string;
subtitle?: string;
welcomeMessage?: string;
placeholder?: string;
persistMessages?: boolean;
storageKeyPrefix?: string;
requestTimeoutMs?: number;
theme?: "light" | "dark" | "auto";
accentColor?: string;
position?: "bottom-right" | "bottom-left" | "top-right" | "top-left";
locale?: "en" | "es" | "fr" | "de";
translations?: Partial<ClaudiusTranslations>;
triggers?: Trigger[];
}

Defaults and semantics: widget options reference.

type Trigger =
| { on: "time"; seconds: number; matchUrl?: string | RegExp; action: TriggerAction }
| { on: "scroll"; percent: number; matchUrl?: string | RegExp; action: TriggerAction }
| { on: "exit-intent"; matchUrl?: string | RegExp; action: TriggerAction }
| { on: "url"; pattern: string | RegExp; action: TriggerAction };
type TriggerAction = "open" | { greeting: string };

All UI strings; see the key table. Partial<ClaudiusTranslations> merges over the resolved locale.

GlobalDirectionPurpose
window.ClaudiusConfigyou → widgetConfiguration object read at load; same keys as ChatWidgetProps
window.ClaudiusWidgetVersionwidget → youThe bundle’s release version ("dev" for local builds)

Registered automatically when the embed bundle loads. Attributes (kebab-case scalar options only): api-url (required), title, subtitle, welcome-message, placeholder, persist-messages, storage-key-prefix, request-timeout-ms, theme, accent-color, position. Attribute changes re-render the widget.

With persistMessages (default on), history is stored in sessionStorage under <storageKeyPrefix> — it survives page navigation and clears when the tab closes. Trigger dismissals are stored under claudius:triggers:dismissed.