mountWidget
Every option mountWidget accepts, and what each one changes.
import { mountWidget, type WidgetHandle } from "@oprag/sdk/widget";
const widget: WidgetHandle = await mountWidget({
projectId: "proj_abc123",
embedKey: import.meta.env.PUBLIC_OPRAG_EMBED_KEY,
apiUrl: "https://api.dev.oprag.ai",
}); Options
| Option | Type | Required | Description |
|---|---|---|---|
projectId | string | Yes | Project whose documents answer the questions. |
embedKey | string | Yes | embed_live_ or embed_test_. An sk_* key throws OpragConfigError. |
apiUrl | string | Yes | API base URL, e.g. https://api.dev.oprag.ai. |
target | HTMLElement | No | Renders the panel inside this element instead of floating it. |
launcher | boolean | No | false hides the default launcher button; open the panel yourself. |
theme | Partial<WidgetTheme> | No | Merged over the project's theme. See theming. |
onReady | () => void | No | Fires once the widget is mounted and configured. |
onOpen / onClose | () => void | No | Panel opened or closed. |
onLead | ({ leadId, projectId }) => void | No | A lead was captured. See events. |
onEscalate | ({ conversationId, projectId }) => void | No | The visitor asked for a human. |
onError | ({ status?, message, code? }) => void | No | A request failed. |
The REST call underneath is GET /v1/widget/{projectId}/config.
Ready to ship?
Get started free