Add an AI chatbot to a Next.js or React site
Drop WebsiteChatbot into your Next.js or React app with a single script, trained on your public pages.
How to add a chatbot to Next.js and React
- In WebsiteChatbot, create your chatbot and enter your site address.
- Copy the script URL and attributes from your embed code.
- In Next.js (App Router), add it to
app/layout.tsxwith<Script src="…" strategy="afterInteractive" />fromnext/script, keeping the data attributes from your embed code. In a plain React app, add the script tag toindex.html. - Deploy. The chat bubble appears on every route.
Good to know
Single-page apps render content in the browser. Our crawler reads the HTML your server sends, so make sure important pages are server-rendered or listed in your sitemap. You can also upload docs as PDF or paste text in the Files & text tab.
Prefer not to touch code? Choose done-for-you setup and we'll install it for you. New to chatbots? Read how to add a chatbot to your website.
Next.js and React tips
Server-rendered content
The chatbot learns from the HTML your server returns. Pages built only in the browser may be missed; use SSR or static generation for key pages, or upload the content as text.
Content Security Policy
If you set a CSP in middleware or next.config, allow https://websitechatbot.com in script-src and connect-src.
Preview deployments
The widget works on preview URLs too, so you can test before merging.
Troubleshooting
Widget loads twice
Add the script once in the root layout, not in individual pages or components that re-mount.
Hydration warnings
Use next/script rather than a raw <script> tag in JSX.
Frequently asked questions
Does it work with the Pages Router?
Yes. Add the Script to pages/_app.tsx (or _document) instead of app/layout.tsx.
Does it work with Vite, Remix or Gatsby?
Yes. Add the script tag to the HTML template or root component so it loads once.
Can you install it for me?
Yes. Our $299 done-for-you setup includes training, testing and installing the chatbot on your Next.js and React site.
Create your free AI chatbot
Enter your email and we'll send you a secure sign-in link. Your chatbot can be live on your website in minutes.
- Free plan, no credit card
- Trained on your website in minutes
- One line of code to install