All installation guides

Developer guide

Add Ascenta Chat to Next.js

One Script tag in the root layout.

About 5 minutes

  1. 1

    Open app/layout.tsx (or pages/_app.tsx)

  2. 2

    Add the Script component inside <body>

    import Script from 'next/script'
    
    // inside <body>, after {children}
    <Script src="http://localhost:3000/widget.js" data-company-id="YOUR_WIDGET_KEY" strategy="afterInteractive" />
  3. 3

    If the site sets a Content-Security-Policy, allow our address

    Add http://localhost:3000 to script-src, frame-src and connect-src. A missing directive fails silently in production.

  4. 4

    Deploy

  5. 5

    Open your website in a new tab

    The chat button appears in the bottom corner within a second. If you do not see it, refresh once. Your dashboard shows "Live" the first time it loads.

How you know it worked

  • Open the published website, not the builder preview.
  • The chat button appears in the bottom corner within a second.
  • The Add to website page in your dashboard changes to “Your chat is live”.