Embed the Maison concierge chat widget in a Next.js application. Both the App Router and Pages Router are supported. Next.js official site ↗
window does not exist on the server. Always access it inside useEffect (App Router) or in a useEffect in _app.tsx (Pages Router) — both run only in the browser.Prerequisites
- Next.js 13+ (App Router) or Next.js 12+ (Pages Router)
- Your Client UUID — find it in the Business Console under Settings
App Router
Create a MaisonChat client component
The
'use client'directive is required at the top of the file — it marks the component as a client component souseEffectandwindoware accessible.Add MaisonChat to your root layout
Import and render the component inside
app/layout.tsx. Server components can import client components — Next.js handles the boundary automatically.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.
Pages Router
Add the widget to pages/_app.tsx
Place the script injection directly in
pages/_app.tsxusinguseEffect. The empty dependency array ensures it runs once after the initial render.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
useEffect or access window. The MaisonChat component file must start with 'use client' as its very first line.window does not exist on the server. Never write const mcbs = window.initMcbs(...) outside a useEffect callback. The entire call must be inside the effect, after the script loads._app.tsx (Pages Router).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.