XACUBE
DocumentationLive chat for…Privacy and security
Start free
Getting startedInstall guidesPlugin releasesUsing the inboxLive visitorsImages and drawingCustomising the chat windowWordPress plugin and inboxInbox in your own admin panelYour team and rolesRecognising signed-in customersPlans and how long chats are keptPrivacy and security

Install the live chat widget on Next.js

XACUBE puts a live chat widget on your Next.js site, so your live agents can answer visitors the moment they ask, from one shared inbox. The free plan covers one agent.

Why XACUBE live chat on Next.js

  1. Add the Script to your root layout, app/layout.tsx.
  2. Publish your site. The chat appears on every page.
import Script from 'next/script'

export default function RootLayout({ children }) {
  return (
    <html>
      <body>
        {children}
        <Script src="https://chat.xacube.chat/w.js" data-key="YOUR_PUBLIC_KEY" strategy="afterInteractive" />
      </body>
    </html>
  )
}

Replace YOUR_PUBLIC_KEY with your own key. In your panel, open your website and this code is shown with your key already in it.

Recognise signed-in customers

import { createHmac } from 'node:crypto'
import Script from 'next/script'

// In a Server Component, so the secret never reaches the browser.
const hash = createHmac('sha256', process.env.XACUBE_SECRET_KEY!).update(String(user.id)).digest('hex')

<Script src="https://chat.xacube.chat/w.js" data-key="YOUR_PUBLIC_KEY"
  data-user-id={String(user.id)} data-user-hash={hash}
  data-user-name={user.name} data-user-email={user.email} strategy="afterInteractive" />

Related

Live chat for your site

Live chat for Next.jsAdd live chat to a Next.js app with next/script in your root layout, and verify signed-in users in a Server Component. No npm package to install.Live chat for web agenciesLive chat for web designers and agencies: add it to every client site in minutes, on WordPress or any stack, and give each client a private inbox.Live chat for service businessesLive chat for service companies, from repairs and cleaning to legal and design: answer quote requests while the customer is choosing who to hire.

Other install guides

ReactVueNuxtAngularSvelteAstro