Skip to main content

Installation

Choose the integration method that fits your application.
You’ll need your Application ID from the Moss Dashboard. You’ll also need a JWT signing key — see Authentication.

NPM Package (React)

For React 17+ applications.

Install

Basic Setup

Add AgentProvider and AssistantButton to your app. The provider does not need to wrap your entire application — just the Moss components.
App.tsx
AgentProvider only needs to wrap the Moss UI components (AssistantButton). It observes the full page DOM regardless of where it sits in the React tree.

Peer Dependencies

The SDK requires React 17 or 18 as a peer dependency:

CDN Script Tag

For any web application, regardless of framework.

Basic Setup

Add the script tag to your HTML. The SDK auto-initializes and renders the assistant button.

Configuration via JavaScript

For more control, configure via window.mossSettings before the script loads:

Global API

After initialization, a global window.MossSDK object is available:

Custom Triggers

Open the assistant from any element using the data-moss-trigger attribute — no hooks required.
This works with any element: buttons, links, nav items, or custom components. The SDK listens for clicks on elements with this attribute and toggles the chat modal.

Examples

React Component

The attribute works inside React components without needing useAgent(). Useful for simple triggers without state management.

Without AssistantButton

You can use custom triggers instead of the built-in button:

TypeScript Constant

The SDK exports the attribute name for programmatic use:

Framework Examples

app/layout.tsx

Next Steps

Authentication

Set up JWT token authentication

Configuration

Configure SDK behavior and options