Use the built-in next/script component — works with App Router and Pages Router.
FoxChat adds an AI chat bubble named the FoxChat AI Operator (you name it yourself) to your Next.js app. Your AI operator reads your published pages and answers visitor questions automatically. The cleanest way to load it in Next.js is the framework's own next/script component with strategy="afterInteractive", so the bubble loads after your page is interactive and never blocks rendering. Add it once in your root layout and it appears on every route.
In app/layout.tsx, import next/script and render it inside the <body>, just before the closing tag:
Replace YOUR_SITE_ID with the ID from your FoxChat dashboard.
On the Pages Router, add the same <Script> tag inside the returned markup of pages/_app.tsx, after the <Component {...pageProps} /> line. The import and props are identical.
If you would rather not use next/script, you can drop a plain <script src="https://getfoxchat.com/widget.js" data-site="YOUR_SITE_ID" defer></script> just before </body> in a custom pages/_document.tsx. Both approaches load your AI operator site-wide.
Start your dev server to confirm the bubble appears, then deploy. Your AI operator loads with zero impact on your page bundle.
Make sure the strategy is afterInteractive and the Script sits inside <body>. Open the browser console and check for blocked requests, and confirm the site ID is correct.
Move the bubble to the opposite corner from your FoxChat dashboard — no code change needed.
Delete the <Script> element (or the plain script tag) from your layout and redeploy.
Compare plans on the pricing page.