Skip to guide

TrolyPage

An autonomous Marketing & Sales operating system for businesses that want AI-powered omni-channel growth.

Contact Info

Follow Us

Install Website Chat on Next.js

Load the widget in an App Router layout with next/script and values from Studio.

View the steps

Where the code goes

A map of the platform UI. Labels can vary slightly by version or account language.

  1. app/layout.tsx
  2. next/script
  3. afterInteractive
  4. Deploy
Illustration of adding the embed code to a website layout file, then checking the widget on the deployed page.
Original TrolyPage illustration, not a Next.js screenshot. Follow the path and steps below.
Next.js App RouterInterface guide
Navigate to
app
layout.tsx
next/script
Choose this location

app/layout.tsx

next/script
<Script
  src="YOUR_STUDIO_WIDGET_SCRIPT_URL"
  data-token="YOUR_CHANNEL_TOKEN"
  data-server="YOUR_STUDIO_SERVER_URL"
  strategy="afterInteractive"
/>
Use your real channel snippet; this shows placement only.Deploy
Original TrolyPage illustration, not a platform screenshot. Labels may vary by version.

Follow each step.

Every step uses your channel’s real Website Chat snippet; the example on the overview page is not deployable.

  1. Publish the channel in TrolyPage Studio and copy the installation snippet to obtain its exact src, data-token, and data-server values.

  2. Open app/layout.tsx, import Script from next/script, and add one Script with strategy="afterInteractive" to the root layout.

  3. Transfer src, data-token, and data-server from the Studio snippet to Script; render only one instance across the app.

  4. Deploy, open a public route, check the widget, and select Check again in Studio.

App Router example

Replace all three values with those in your own channel’s Studio snippet.

import Script from 'next/script'

// Inside app/layout.tsx, within <body>:
<Script
  src="YOUR_STUDIO_WIDGET_SCRIPT_URL"
  data-token="YOUR_CHANNEL_TOKEN"
  data-server="YOUR_STUDIO_SERVER_URL"
  strategy="afterInteractive"
/>

Ask ChatGPT or Claude to install it

Works even if your website is not listed. Replace the placeholder with your Studio snippet, adjust the prompt if needed, then send it to an AI assistant with website access.

The button only copies; it does not send data. Without website access, the assistant should guide you. Never share admin passwords or API keys.

You can edit the text before copying.

Verify the installation

Open a public page with the snippet. Once the widget loads, return to your channel’s Install section in Studio and select Check again. Detection requires a signal from the live website.

Check in Studio

If the widget is missing

  • Do not use example tokens from this article. A widget token is a channel-specific public identifier, not an administrator API key.
  • Confirm the channel is Published and your website domain is allowed.
  • Check that the snippet appears only once and is not blocked by cache, CSP, or script blockers.
  • Open a public page in a private window, then select Check again; builder previews do not replace a live page.

Platform UI steps were checked against official documentation. This is a code-installation method, not a native TrolyPage plugin or app for that platform.

Read Next.js documentation

What can TrolyPage help with?

Pick what you want to improve. TrolyPage will call you with advice tailored to your needs.

Which features interest you?

Choose as many as you like.

Explore TrolyPage featuresWatch the 78-second video

We use your details to respond to your consultation request. Privacy policy