# Add a support chat to a Next.js app

To add a support chat to a Next.js app, put the quiry install code once before `</body>` in `app/layout.tsx`. Messages from visitors arrive in the console under **Inbox**, and if a visitor closes the window, they get an email when you reply.

## Steps

1. In the quiry console, open **Settings**, choose **Add site** to create a site, and put your app address in **Allowed domains**. The full steps are in [Install the widget](/docs/install).
2. On the **Install** tab, choose **Copy code**.
3. Paste it just before `</body>` in the root layout, `app/layout.tsx`.
4. Open the app, click the chat button at the bottom right, and send a test message. If it shows up in the console under **Inbox**, you are done.

```
<script src="https://quiry.me/w.js" data-workspace="my-team" data-widget="my-site" async></script>
```

Use the `data-workspace` and `data-widget` values from your own **Install code**. `my-team` and `my-site` above are examples.

## Ask a coding agent to do it

For an agent such as Cursor, Claude Code or Codex, say this. The agent reads the install doc and puts the code in the right place.

- Read `https://quiry.me/en/docs/install.md` and add the quiry widget to `app/layout.tsx` in this Next.js app.
- Add the install code once, in the layout. Do not add it per page or per component.

Prompts for each builder and agent are in [Add a support chat with Cursor, Claude Code or Codex](/docs/cursor).

## Why only once

In an app that moves between pages, like Next.js, putting the install code in every route can make the widget appear twice. Put it once in the root layout. Call `Quiry.identify` again only when the member's info changes. To link signed-in members, see [Identify logged-in users in the support chat](/docs/identify-users).

Next is [Identify logged-in users in the support chat](/docs/identify-users).
