Skip to content

Add an AI chatbot to your React app.

The ChatBento widget is an external script, and React's docs describe useEffect as the way to synchronize with a system outside React. A ten-line component adds the script once; render it near the root of your app and the chatbot shows on every route.

Start freeFree plan, 50 messages a month. No card required.

Install on React in 5 steps

Where it goes: A <ChatBento /> component rendered once near your app's root

  1. 1

    In ChatBento, open your chatbot, go to Install and copy your bot ID (the data-bot-id value in the snippet).

  2. 2

    Create ChatBento.tsx with the component below.

  3. 3

    Render <ChatBento botId="YOUR_BOT_ID" /> once, near the root of your app (for example in App.tsx).

  4. 4

    Build and deploy.

  5. 5

    Open your live site in a new tab and click the chat bubble in the corner to test it.

ChatBento.tsx

import { useEffect } from "react";

export function ChatBento({ botId }: { botId: string }) {
  useEffect(() => {
    if (document.querySelector("script[data-bot-id][src*='chatbento.com/widget.js']")) return;
    const script = document.createElement("script");
    script.src = "https://chatbento.com/widget.js";
    script.async = true;
    script.dataset.botId = botId;
    document.body.appendChild(script);
  }, [botId]);

  return null;
}

App.tsx

import { ChatBento } from "./ChatBento";

export default function App() {
  return (
    <>
      {/* your routes and layout */}
      <ChatBento botId="YOUR_BOT_ID" />
    </>
  );
}

Steps follow React’s own documentation, checked October 23, 2026.

Or skip the component

In a Vite app, index.html is the entry point to your application. You can paste the plain snippet there, before </body>, instead of using the component.

Strict Mode runs effects twice

In development, React runs an extra setup and cleanup cycle. The component checks for an existing script first, so the widget still loads only once.

Using Next.js?

Use next/script in your root layout instead. The Next.js guide has the full file.

What the chatbot does on your React site

Answers from your content

Trained on your pages, docs and Q&As. It says so when it doesn't know, instead of guessing.

Hands off to you

When a visitor needs a person, it collects their email and sends you the conversation.

Free to start

A free plan with 50 AI messages a month. Paid plans from $8/month: 80% less than Chatbase.

Comparing tools? See ChatBento vs Chatbase and pricing.

React questions. Answered.

Does it keep working across React Router navigation?

Yes. The widget attaches to the page once and stays open while the router swaps views, so a conversation isn't lost between routes.

Can I open the chat from a React button?

Yes: <button onClick={() => window.ChatBento?.open()}>Talk to support</button>. close() and toggle() work too.

Is there an npm package?

No, and you don't need one. The widget is a single script loaded from chatbento.com, so updates reach your site without a new deploy.

How much does ChatBento cost?

ChatBento has a free plan with 50 AI messages a month, free forever. Paid plans are Hobby at $8/month, Standard at $30/month and Pro at $100/month. New accounts start with a 14-day trial, no card required.

Add AI support to your React site. Live in minutes.

14-day free trial. No card required.