Installation steps
- 1
Prepare
Copy the exact snippet and site key from the Install page.
- 2
Configure
In App Router, use
next/scriptinapp/layout.tsxinside the body with the strategy shown in your install instructions.// app/layout.tsx import Script from "next/script" export default function RootLayout({ children }: { children: React.ReactNode }) { return ( <html lang="en"> <body> {children} <Script src="https://mivochat.app/widget.js" data-site="YOUR_SITE_KEY" strategy="afterInteractive" /> </body> </html> ) } - 3
Publish
Keep one loader in the shared layout, or place it in a narrower layout if only selected routes need chat.
- 4
Verify
Allow the production origin, deploy, and test the widget plus a complete team handoff.
Check routing and policy
Keep the script in one shared place so client navigation does not add duplicate loaders. If the app sends a content security policy, add the directives listed in the Content Security Policy guide, including the inline style entry.
A typical root layout imports Script from next/script and renders <Script src="https://mivochat.app/widget.js" data-site="YOUR_SITE_KEY" strategy="afterInteractive" /> inside <body>. Replace the key with the public value from Install; keep the script in a Server Component layout instead of reading window or document during server rendering.
If chat belongs only on product documentation, move the loader into that route group's layout.tsx so pricing and signup screens do not load it. For stricter CSP deployments, compare the production response headers with the browser console's blocked URI and add only the MivoChat origins required by the loader and its requests.
Test production
Preview deployments and local development may use different origins. Add the origin visitors actually use, then send a documented question and an unsupported one from the deployed page.
After deploying, open the canonical hostname in a private window, navigate between two App Router routes, and confirm that only one launcher remains. Ask where to create an API key, then ask for an undocumented feature; the first answer should cite the matching docs page and the second should offer a team handoff.
Before you change the setup
- Who this is for
- a Next.js App Router marketing site that needs a widget across public routes
- What you need
- the App Router root layout,
next/script, the public site key, and the final production hostname - Where it goes
app/layout.tsx, inside the root layout's<body>, usingnext/scriptandstrategy="afterInteractive"- Watch out for
- a root layout persists through client navigation; a loader in a page component can instead be remounted or duplicated
Test the support boundary
- How do I authenticate a request with an API key?
- What is the retry behavior for a failed webhook?
- Can you confirm a feature absent from the docs?
Frequently asked questions
A server render complains about `document`
Do not create a script with browser globals in a Server Component; render Next.js Script from the layout instead.
The launcher disappears after route navigation
Keep the loader in the persistent root layout and test navigation with the browser console open; do not attach it to each route page.
The browser blocks the external loader
Update the production CSP with the MivoChat origin in script-src, frame-src and connect-src, plus style-src 'unsafe-inline'; the Content Security Policy guide has the exact block.
A preview works but production is refused
Add the exact public production origin in Install settings → Allowed websites; preview URLs count as separate origins.
Keep exploring
The r3-final-a evaluation measured 95% answerability-tier accuracy on 224 questions; this is an evaluation result, not a guarantee. AI replies use Anthropic. See the method and results and subprocessors and data locations.