# For developers (/docs/get-started/for-developers)

> Embed the Loopwix chat in your site or app with one script tag, control it from code, and find where the developer docs live.

Type: guide | Status: ga | Last reviewed: 2026-11-21

This page is for developers who need to put the Loopwix chat on a site or app and control it from their own code. Build and publish a working agent first, using a [quickstart](/docs/get-started/choose-your-path); the embed only shows what the agent already does.

## How do I add the Loopwix chat to my site with code? [#how-do-i-add-the-loopwix-chat-to-my-site-with-code]

Publish your agent first, then paste the one script tag from the dashboard into your site or app. The widget talks to your published agent, so you host nothing and build no chat interface. After that, you can control the chat from your own page code.

## What you embed [#what-you-embed]

The website chat is a small widget loaded by one script tag. You do not host anything or build a chat interface. The widget talks to your published agent, and customers see the last published version.

## Embed [#embed]

1. In the dashboard open your agent, then go to **Channels**, website chat, **Install**.
2. Copy the one-line script. It includes your agent's **public key**, which is safe to put in a page.
3. Paste it before the closing `</body>` tag.
4. Add your site's address to **Allowed sites** in [Advanced settings](/docs/channels/website-chat/advanced).

The chat only loads on sites you list there, including `www.` if your site uses it. If it does not appear, the allowed list is the first thing to check.

## Control the chat from your page [#control-the-chat-from-your-page]

- Add `data-loopwix-open` to any button or link to open the chat. See [Install the website chat](/docs/channels/website-chat/install).
- The widget exposes `Loopwix.open()`, `Loopwix.close()`, `Loopwix.toggle()` and `Loopwix.on(event, fn)`. See [JavaScript API](/docs/developers/embed-the-widget#javascript-api).

Typical uses are a "Chat with us" link in a header or a help button that opens the chat from a pricing page.

## Public key and allowed sites [#public-key-and-allowed-sites]

The public key identifies your agent to the widget. It is not a secret, which is why it can appear in page source. Access is limited by **Allowed sites** and abuse protection, not by hiding the key. See [Public keys and allowed sites](/docs/developers/embed-the-widget#public-keys-and-allowed-sites).

Keep real secrets, such as API credentials, inside [Integrations](/docs/integrations), where they are stored encrypted and never shown again.

## Frameworks and security headers [#frameworks-and-security-headers]

- Using React or Next.js? See [React and Next.js](/docs/developers/react-and-next-js).
- A strict Content Security Policy or cookie rules? See [CSP, cookies and privacy](/docs/developers/embed-the-widget#csp-cookies-and-privacy).
- Widget settings you can pass are in [Widget options](/docs/developers/embed-the-widget#widget-options).

## No-code alternative [#no-code-alternative]

If you cannot add a script, share the chat link instead. See [Full page chat](/docs/channels/website-chat/customise#full-page-chat) and the [hosted page and public API](/docs/developers/hosted-page-and-public-api).

## Test before launch [#test-before-launch]

1. Embed on a staging site and add that address to **Allowed sites**.
2. Open the chat on desktop and a phone.
3. Run through the [Go-live checklist](/docs/get-started/go-live-checklist).
4. Before launch, make sure **Allowed sites** lists your real production address.

## Learn more [#learn-more]

- [Developers](/docs/developers) covers embedding, options and keys.
- [Webhooks and roadmap](/docs/developers/webhooks-and-roadmap) explains what is available now and what is planned.
- [Advanced settings](/docs/channels/website-chat/advanced) covers allowed sites and abuse protection.
