Skip to content
AnTalkChat
Framework

Add AnTalkChat to React and Next.js

Load the widget script once in your app's layout. The window.Assistant API lets your own buttons open the chat or ask a question.

Step by step

  1. 1

    Next.js: use next/script

    Add the script to your root layout (app/layout.tsx) with the afterInteractive strategy, as below.

  2. 2

    React (Vite or similar)

    Paste the plain script tag before </body> in index.html.

  3. 3

    Open it from your UI

    Call window.Assistant.open() from a "Chat with us" button, or window.Assistant.send('…') to ask a question for the visitor.

Your snippet

TSX
import Script from 'next/script';

export default function RootLayout({ children }) {
    return (
        <html lang="en">
            <body>
                {children}
                <Script
                    src="https://antalkchat.com/widget/v1.js"
                    data-assistant="ast_pub_YOUR_ID"
                    strategy="afterInteractive"
                />
            </body>
        </html>
    );
}

Good to know

  • Load the script once, not in every component: the widget keeps its own state.
  • Events: ready, open, close, message, error — listen with window.Assistant.on('message', …).
Read the full install guide

Give your website an assistant that knows your business

Add your web pages and notes, paste one line on your site, and let visitors get answers and book appointments any time of day.

Free for 30 days · No credit card required · Live in minutes