# Add Reponly live chat to a website

> Add the Reponly chat widget to any website or web app with one script tag: plain HTML, Next.js, React, Vue, Svelte or anything else that serves HTML.

Reponly is human-first live chat for founders who run more than one product. Each product (a website or an app) gets its own project key, and every product's chats land in the same inbox. Replies come from people, not a bot.

## 1. Create a product

1. Create a free account at [https://reponly.com/signup](https://reponly.com/signup).
2. Create a product for each website or app you want chat on. There is no limit on any plan.
3. Open the product's **Install** tab and copy its project key (`pk_...`). The key is public and safe in front-end code.

## 2. Add the script

Paste this before `</body>` on every page that should show the chat button:

```html
<script src="https://reponly.com/widget.js" data-project="pk_your_project_key" async></script>
```

`data-theme` is optional: `"light"` (default), `"dark"` or `"auto"` (follows the visitor's system setting).

## Next.js

Load it once in the root layout with `next/script`, so it stays loaded across client-side navigation:

```tsx
// app/layout.tsx
import Script from "next/script";

export default function RootLayout({ children }: { children: React.ReactNode }) {
  return (
    <html lang="en">
      <body>
        {children}
        <Script
          src="https://reponly.com/widget.js"
          data-project="pk_your_project_key"
          strategy="afterInteractive"
        />
      </body>
    </html>
  );
}
```

## React, Vue, Svelte and other single-page apps

Put the script tag in the `index.html` your app is served from. Don't add it from a component that mounts and unmounts: the widget only needs to load once per page.

## Control the widget from your code

```js
window.Reponly.open();     // open the chat
window.Reponly.close();
window.Reponly.toggle();
window.Reponly.setTheme("dark"); // "light" | "dark" | "auto", e.g. from your own theme toggle
window.Reponly.identify(identityToken); // signed-in users, see "Identify signed-in users"
window.Reponly.logout();   // on sign-out

// Calls made before widget.js has loaded can be queued:
window.Reponly = window.Reponly || { q: [] };
window.Reponly.q.push(["open"]);
```

## Optional settings

- **General** tab: when to ask visitors for an email, and **Allowed domains**: list your sites so the chat can only be embedded there. With none listed, it works on any site.
- **Widget** tab: brand colour, welcome message and position on the page.
- Visitors who leave an email and go before you reply get your answer by email, with a link back to the chat.
- To show signed-in users the same chat on every device, see [Identify signed-in users](https://reponly.com/docs/identify).
- To build your own chat UI instead of the widget, see [Build a custom chat UI](https://reponly.com/docs/custom-ui).
