Embed the Maison concierge chat widget in a React application using a reusable component that handles script loading and cleanup via useEffect. React official site ↗
Prerequisites
- React 16.8+ (hooks support required)
- Your Client UUID — find it in the Business Console under Settings
- A client-side rendering context (not SSR — see note below)
Steps
Create the MaisonChat component
Create a new file
MaisonChat.tsxin your components folder. The component injects the bundle script on mount and removes it on unmount, so it is safe to use in a component tree.Render MaisonChat in your app
Import and render the component near the root of your application. Pass your Client UUID as the
clientIdprop.Optionally wire up session callbacks
If you need to persist or observe the session ID (for example to resume a conversation), extend the component to accept an
onSessionUpdateprop.Verify in DevTools
Open your browser DevTools, switch to the Elements tab, and look for
#maison-chat-iconin the DOM. If it's present, the widget initialised correctly.
For the full list of configuration options, control methods, and callbacks, see the Widget SDK Reference.
Common mistakes
script.src and immediately calling window.initMcbs() will fail because the script has not finished loading. Always call initMcbs inside script.onload.window does not exist on the server. This component is safe because useEffect only runs in the browser. Do not import or call initMcbs at module level in any file that may be server-rendered.MaisonChat is rendered in multiple places simultaneously, multiple script tags will be injected. Keep a single instance at the top level of your app (e.g. in App.tsx or the root layout).bottom: 20, not bottom: '20px'. Values are plain numbers representing pixels — do not include units.Not sure if it's set up correctly? Use the Site Diagnostic tool.