mountWidget

Every option mountWidget accepts, and what each one changes.

Browser Embed key dev · https://api.dev.oprag.ai
TypeScript
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

OptionTypeRequiredDescription
projectIdstringYesProject whose documents answer the questions.
embedKeystringYesembed_live_ or embed_test_. An sk_* key throws OpragConfigError.
apiUrlstringYesAPI base URL, e.g. https://api.dev.oprag.ai.
targetHTMLElementNoRenders the panel inside this element instead of floating it.
launcherbooleanNofalse hides the default launcher button; open the panel yourself.
themePartial<WidgetTheme>NoMerged over the project's theme. See theming.
onReady() => voidNoFires once the widget is mounted and configured.
onOpen / onClose() => voidNoPanel opened or closed.
onLead({ leadId, projectId }) => voidNoA lead was captured. See events.
onEscalate({ conversationId, projectId }) => voidNoThe visitor asked for a human.
onError({ status?, message, code? }) => voidNoA request failed.

The REST call underneath is GET /v1/widget/{projectId}/config.

Ready to ship?

Get started free