> For the complete documentation index, see [llms.txt](https://docs.convai.com/api-docs/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.convai.com/api-docs/plugins-and-integrations/web-plugins/convai-embody/react-api-reference.md).

# React API reference

Reference for the Convai Embody React components and hooks, including every prop, its type and default, and what each hook returns.

The React API is exported from `@convai/embody/react`. Every component and hook here also accepts the character options documented in the [createCharacter reference](https://docs.convai.com/api-docs/plugins-and-integrations/web-plugins/convai-embody/createcharacter-reference.md), such as `characterId`, `token`, and `apiKey`.

Changing one of those options reloads the body, with one exception: a new `correctiveMap` is applied to the running character, so switching maps does not interrupt speech.

### ConvaiCharacter

A self-contained character view: a `<Canvas>`, a camera, a portrait light rig, orbit controls, and the character. The key light sits 45° to the left of the camera, follows it as you orbit, and casts soft shadows; a fill, a rim and a dim environment complete it, with Neutral tone mapping. It is both a named export and the default export of `@convai/embody/react`.

| Prop         | Type                                                                                       | Default                                                                    | Description                                                                                                                                                 |
| ------------ | ------------------------------------------------------------------------------------------ | -------------------------------------------------------------------------- | ----------------------------------------------------------------------------------------------------------------------------------------------------------- |
| `style`      | `React.CSSProperties`                                                                      | `{ width: '100%', height: '100%', minHeight: '100vh' }`, merged with yours | Wrapper style.                                                                                                                                              |
| `className`  | `string`                                                                                   | none                                                                       | Wrapper class name.                                                                                                                                         |
| `background` | `string \| null`                                                                           | `'#17181c'`                                                                | Scene background color. `null` renders transparent so the page shows through.                                                                               |
| `camera`     | `{ position?: [number, number, number]; fov?: number; target?: [number, number, number] }` | `position: [0, 1.45, 3.6]`, `fov: 35`, `target: [0, 0.92, 0]`              | Camera framing in meters.                                                                                                                                   |
| `orbit`      | `boolean \| OrbitOptions`                                                                  | `true`                                                                     | Drag to turn around the character and scroll to move in and out. `false` fixes the camera. An object tunes the limits.                                      |
| `fallback`   | `React.ReactNode`                                                                          | `null`                                                                     | Rendered while the body loads.                                                                                                                              |
| `onReady`    | `(character: CharacterHandle) => void`                                                     | none                                                                       | Called once for each character that loads, when the body is loaded and the connection is live. An inline function is fine: re-renders do not call it again. |
| `onError`    | `(error: Error) => void`                                                                   | none                                                                       | Called with the error that stopped loading.                                                                                                                 |
| `queue`      | `BlendshapeQueue`                                                                          | the character's own session                                                | Overrides which turn this body lip-syncs to. Only needed when one client drives several characters.                                                         |

All [createCharacter options](https://docs.convai.com/api-docs/plugins-and-integrations/web-plugins/convai-embody/createcharacter-reference.md#options) are accepted as props.

### CharacterModel

The character alone, for use inside a `<Canvas>` you create. It adds no camera, lights, or controls.

| Prop      | Type                                   | Default                     | Description                                                                                                                                                 |
| --------- | -------------------------------------- | --------------------------- | ----------------------------------------------------------------------------------------------------------------------------------------------------------- |
| `onReady` | `(character: CharacterHandle) => void` | none                        | Called once for each character that loads, when the body is loaded and the connection is live. An inline function is fine: re-renders do not call it again. |
| `onError` | `(error: Error) => void`               | none                        | Called with the error that stopped loading.                                                                                                                 |
| `queue`   | `BlendshapeQueue`                      | the character's own session | Overrides which turn this body lip-syncs to.                                                                                                                |
| `shadows` | `boolean`                              | `false`                     | Every mesh of the character casts and receives shadows. Your lights decide whether any are cast.                                                            |

All [createCharacter options](https://docs.convai.com/api-docs/plugins-and-integrations/web-plugins/convai-embody/createcharacter-reference.md#options) are accepted as props.

### OrbitOptions

Passed as the `orbit` prop of `ConvaiCharacter`, or as `options` to `OrbitRig`.

| Field             | Type      | Default          | Description                                                                                           |
| ----------------- | --------- | ---------------- | ----------------------------------------------------------------------------------------------------- |
| `minDistance`     | `number`  | `0.6`            | Closest the camera may come, in meters.                                                               |
| `maxDistance`     | `number`  | `8`              | Furthest the camera may move away, in meters.                                                         |
| `minPolarAngle`   | `number`  | `Math.PI * 0.12` | Highest the camera may rise, in radians from straight up.                                             |
| `maxPolarAngle`   | `number`  | `Math.PI * 0.52` | Lowest the camera may sink, in radians from straight up. Beyond `Math.PI / 2` it looks up from below. |
| `enablePan`       | `boolean` | `false`          | Drag the character around the frame.                                                                  |
| `enableZoom`      | `boolean` | `true`           | Scroll to move in and out.                                                                            |
| `autoRotate`      | `boolean` | `false`          | Turn slowly around the character on its own.                                                          |
| `autoRotateSpeed` | `number`  | `1.2`            | Speed while `autoRotate` is on.                                                                       |

### OrbitRig

Orbit controls for a `<Canvas>` you create around `CharacterModel`, matching the behavior `ConvaiCharacter` provides.

| Prop      | Type                       | Default            | Description                                                                                   |
| --------- | -------------------------- | ------------------ | --------------------------------------------------------------------------------------------- |
| `target`  | `[number, number, number]` | required           | The point the camera orbits, in meters. Use the character's head height rather than its feet. |
| `options` | `OrbitOptions`             | the defaults above | Orbit limits.                                                                                 |

### useCharacter

```tsx
function useCharacter(options: UseCharacterOptions): UseCharacterResult
```

Loads a character and returns it. `UseCharacterOptions` is every [createCharacter option](https://docs.convai.com/api-docs/plugins-and-integrations/web-plugins/convai-embody/createcharacter-reference.md#options) plus `queue`. Must be called inside a `<Canvas>`.

| Field       | Type                              | Description                                                             |
| ----------- | --------------------------------- | ----------------------------------------------------------------------- |
| `character` | `CharacterHandle \| null`         | The loaded character, or `null` until it is ready.                      |
| `client`    | `ConvaiClient \| null`            | The connected client once ready. The same object as `character.client`. |
| `error`     | `Error \| null`                   | The error that stopped loading.                                         |
| `status`    | `'loading' \| 'ready' \| 'error'` | `'loading'` until the body and the connection are both up.              |

### When the character reloads

The components and `useCharacter` load the character again, and close and reopen its connection, only when one of these props changes: `characterId`, `token`, `authToken`, `apiKey`, `baseUrl`, `onPrem`, `resolver`, or `modelVariant`. Compare `resolver` by identity: define it outside the component or memoize it.

`camera` and `correctiveMap` apply to the loaded character without a reload. Every other option, such as `animations`, `idleClip`, `session`, `client`, and `decorators`, is read once when the character loads; to change one, remount the component with a new `key`.

### useWidgetClient

```tsx
function useWidgetClient(client: ConvaiClient | null): WidgetClient | null
```

Adapts a character's `ConvaiClient` to the `convaiClient` prop of `ConvaiWidget`, without opening a second connection. Returns `null` while `client` is `null`. `WidgetClient` is `ConvaiClient` plus `activity`, `isAudioMuted`, `isVideoEnabled`, and the other state fields the widget reads.

Only needed with `@convai/web-widget` before 0.3.0. From 0.3.0, `ConvaiWidget` takes the character's `ConvaiClient` directly.

### Re-exported from the Convai Web SDK

These are the Convai Web SDK's own exports, re-exported unchanged.

| Export            | Kind                                                                                             |
| ----------------- | ------------------------------------------------------------------------------------------------ |
| `useConvaiClient` | React hook. Constructs a separate client and connection; do not use it for a character's widget. |
| `ConvaiClient`    | Class                                                                                            |
| `ConvaiConfig`    | Type                                                                                             |

Convai Embody is the 3D character only. The chat UI (`ConvaiWidget`, and the React `AudioRenderer` and `AudioContext`) is in `@convai/web-widget/react`.

### Related reference

{% content-ref url="/pages/ZpHdQxttnTv6NSyjlTWl" %}
[createCharacter reference](https://docs.convai.com/api-docs/plugins-and-integrations/web-plugins/convai-embody/createcharacter-reference.md)
{% endcontent-ref %}


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## Querying This Documentation
If you need additional information that is not directly available in this page, you can query the documentation by asking a question.

Perform an HTTP GET request on the following URL with the `ask` and `goal` query parameters:

```
GET https://docs.convai.com/api-docs/plugins-and-integrations/web-plugins/convai-embody/react-api-reference.md?ask=<question>&goal=<user_goal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is what the user is ultimately trying to achieve, the reason they need the answer. Sharing it helps GitBook give you a better, more relevant answer. A goal is most helpful when it describes the outcome the user wants rather than restating the question. For example, with `ask=how do I create an API token`, a goal like `automate deployments from our CI pipeline` lets GitBook tailor the answer to that use case.

The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
