Home › Chatbot for Next.js and React
Works with Next.js and React

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

  1. In WebsiteChatbot, create your chatbot and enter your site address.
  2. Copy the script URL and attributes from your embed code.
  3. In Next.js (App Router), add it to app/layout.tsx with <Script src="…" strategy="afterInteractive" /> from next/script, keeping the data attributes from your embed code. In a plain React app, add the script tag to index.html.
  4. 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.

FAQ

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.

Get started

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

Start free

No password needed. We'll email you a sign-in link.

Already have an account? Log in