---
name: tavus-embed
description: Add a Tavus face-to-face video agent (PAL) to a web page or app with the <tavus-embed> custom element from @tavus/embed. Use when installing @tavus/embed, placing <tavus-embed> in HTML, React, Next.js, Vue, Svelte or another framework, sizing it, pointing it at a non-production API, or listening to its tavus:* events.
---

# @tavus/embed

`<tavus-embed>` renders a complete Tavus conversation inline: preview, start button, device check, live call, captions, chat and the after-call screen. The page needs no backend and no API key. It needs one deployment id.

For a floating launcher in the page corner instead of an inline surface, use `@tavus/widget`.

## Install

Bundled app:

```bash
npm install @tavus/embed
```

```ts
import "@tavus/embed"; // registers <tavus-embed> as a side effect and ships JSX typings
```

Static page from a CDN:

```html
<script src="https://unpkg.com/@tavus/embed@latest"></script>
```

Static page from the installed package, without a bundler: serve or copy `node_modules/@tavus/embed/dist/index.iife.js` and load it with a plain `<script>` tag. `dist/index.mjs` is the ESM build for bundlers.

## Minimal working page

```html
<div style="width: 720px; aspect-ratio: 16 / 9;">
  <tavus-embed deployment-id="YOUR_DEPLOYMENT_ID"></tavus-embed>
</div>
```

The element fills its parent (`width: 100%; height: 100%`). A parent with no definite size gives a collapsed or oddly sized element. Give the parent a width plus a height or an `aspect-ratio`.

## Frameworks

- Attribute names are kebab-case strings in every framework: `deployment-id`, not `deploymentId`. JSON attributes take a string: `override-config={JSON.stringify({...})}`.
- React and Vite: import `@tavus/embed` once at module top level and render `<tavus-embed deployment-id="..." />`. Keep the import static. A lazy `import("@tavus/embed")` makes Vite re-optimise dependencies mid-session. Type a ref as `useRef<TavusElement>(null)` with `import type { TavusElement } from "@tavus/embed"`.
- Next.js, Remix, Nuxt, SvelteKit: the element is browser-only. Import it in a client component (`"use client"`), after mount, or on a route with SSR off. Do not import it in a server component.
- Vue: tell the compiler the tag is a custom element, or Vue warns that it cannot resolve the component: `vue({ template: { compilerOptions: { isCustomElement: (tag) => tag.startsWith("tavus-") } } })` in `vite.config`.
- Svelte: event names contain a colon, so `ontavus:ready` does not compile. Attach listeners with `addEventListener` in `onMount` or `$effect`.

## Attributes

| Attribute                | Value                     | Use                                                                                                         |
| ------------------------ | ------------------------- | ----------------------------------------------------------------------------------------------------------- |
| `deployment-id`          | string                    | Required. The deployment to load.                                                                           |
| `base-url`               | origin                    | API origin, without a path. Defaults to `https://tavusapi.com`. Set it only for a non-production Tavus API. |
| `layout`                 | `inline` \| `full-screen` | Preview arrangement. `full-screen` for a section that owns the viewport.                                    |
| `expand-options`         | JSON string               | Lift the card into a modal for the call, for example `{"enabled":true,"aspect":"vertical"}`.                |
| `override-config`        | JSON string               | Deep-merged over the fetched deployment config.                                                             |
| `conversational-context` | string                    | What the agent knows about this visitor or page.                                                            |
| `custom-greeting`        | string                    | The agent's first line.                                                                                     |
| `memory-stores`          | comma-separated           | Stable per-visitor ids (a user id, never a shared value).                                                   |
| `camera-on-start`        | `on` \| `off`             | Visitor camera at start. Defaults to `on`.                                                                  |

## Events and methods

Events bubble to `document`. Methods exist only after `tavus:ready`, so the types mark them optional.

```ts
const el = document.querySelector("tavus-embed"); // typed as TavusElement
el?.addEventListener("tavus:ready", () => {});
el?.addEventListener("tavus:conversation-started", (e) => {});
el?.addEventListener("tavus:conversation-ended", (e) => {});
el?.addEventListener("tavus:error", (e) => {}); // detail: { code, message }
el?.addEventListener("tavus:tool-call", (e) => {});

el?.startConversation?.();
el?.endConversation?.();
el?.sendMessage?.({ event_type: "conversation.respond", properties: { text: "Hi" } });
```

`tavus:ready` fires once. Code that subscribes late should check `typeof el.startConversation === "function"` first. In a bundled app, `import { TavusIntegration } from "@tavus/embed"` gives typed `detail` payloads over the same API.

## Requirements that fail silently

- HTTPS or `http://localhost`. On plain http the element shows "PAL is unavailable".
- Inside a cross-origin `<iframe>`, add `allow="microphone; camera"`, or the browser blocks the microphone.
- The deployment's allowed origins must include the page origin, or `/init` is refused.

## Check that it works

1. Load the page. The element shows the agent preview and a Start button, not "PAL is unavailable". The preview can show a placeholder for a few seconds before the video appears.
2. In the network panel, `GET {base-url}/v2/deployments/{id}/init` returns 200.
3. Listen for `tavus:ready` and `tavus:error`. An error event carries a `code` that names the cause.

Full reference: https://docs.tavus.io/sections/deployments/embed and https://docs.tavus.io/sections/deployments/host-communication. Agent index: https://docs.tavus.io/llms.txt.
