MojarMojar
DevelopersEmbed SDK

Install the SDK

Add the Mojar chat widget to any website using the loader script or an npm package.

There are two ways to add the Mojar chat widget to a site. The loader script is the confirmed, production-ready path. The @mojar/sdk npm packages are the alternative for bundled JavaScript applications.

Prerequisites

Before adding the widget you need:

  • An agent UUID — found on the Website Embed tab of your agent in mojar.ai.
  • A domain UUID — generated when you register your site's domain on the same tab.

See embed widget — domains for how to register a domain and retrieve both UUIDs.

Add a single <script> tag to your HTML. The script self-initialises; no additional JavaScript is required.

index.html
<script
  src="https://app.mojar.ai/widget-mojar-loader.js"
  data-agentid="YOUR_AGENT_UUID"
  data-domainuuid="YOUR_DOMAIN_UUID"
></script>

The loader:

  1. Validates the agent and domain by calling /api/embed/initiate-session on the Mojar host.
  2. Injects an animated toggle button into the page.
  3. Creates an iframe pointing to the embed chat route when the button is first clicked (lazy load).
  4. Handles token refresh silently in the background.

You can place the <script> tag anywhere in the document. It runs once even if included multiple times.

For full attribute reference (button position, theme, colors, and more) see embed widget — configuration.

For the full technical breakdown of boot sequence, JS API, and postMessage events see loader script.

Option 2 — npm packages

Two npm packages are available for bundled apps:

PackageUse case
@mojar/sdkFramework-agnostic TypeScript — any bundled app
@mojar/sdk-reactReact ≥18 bindings that wrap @mojar/sdk
npm
npm install @mojar/sdk
# or for React
npm install @mojar/sdk-react

If you only need the widget on a static site or a server-rendered app, the loader script requires zero build tooling and is the simpler choice.

On this page