@daxov/react
A drop-in Conversation component and a useCall() hook for live calls with your character in a React app.
@daxov/react puts a live call in a React 18+ app: <Conversation> is the whole thing (the face, the AI badge, mute, end, a joining state), and useCall() is the hook under it, for your own UI. Both use @daxov/client.
The package is private until the product has its name; @daxov/react is a placeholder name. The code below shows how it will be used.
<Conversation>
import { Conversation } from "@daxov/react";
import "@daxov/react/theme.css"; // optional: the default look
export function Call() {
return (
<Conversation
name="Alex"
getCallStart={() => fetch("/api/calls", { method: "POST" }).then((r) => r.json())}
>
<p className="conversation-note">Your microphone is used only while the call is on.</p>
</Conversation>
);
}getCallStart asks your server for a call: your endpoint calls POST /v1/calls with your secret key and answers forBrowser(start). It's called after the microphone is open, from the Start button's click.
Props
Prop
Type
Labels
Every word is in labels. The defaults:
| Label | Default |
|---|---|
start | Start the call |
again | Call again |
allowMic | Allow the microphone when your browser asks. |
joining | Joining… |
mute, unmute | Mute, Unmute |
end | End |
ended | The call has ended. |
aiBadge | AI |
aiBadgeTitle | You're talking to an AI, not a person. |
you, ai | You, AI (in the transcript) |
The AI badge is always shown; only its words change.
Styling
Without theme.css, <Conversation> is plain, unstyled elements: a root with the class conversation and parts with conversation-… classes (conversation-stage, conversation-controls, conversation-button, conversation-ai-badge, conversation-transcript…). The root carries its state as data attributes:
| Attribute | Values |
|---|---|
data-phase | idle, opening, connecting, live, ended, failed |
data-face | off, joining, waiting, live, failed, ended |
data-speaking | true while the AI speaks |
data-muted | true while the microphone is muted |
With theme.css, set its variables with a class of yours. Every rule in it sits in :where(), so your class wins without a fight:
.my-call {
--conversation-accent: #1d6ad3;
--conversation-radius: 8px;
}The variables: --conversation-bg, -fg, -muted-fg, -border, -stage-bg, -stage-fg, -accent, -on-accent, -danger, -on-danger, -badge-bg, -badge-fg, -radius, -aspect (4 / 3 by default) and -font. It follows the visitor's light or dark setting; data-theme="light" or "dark" on the component fixes it.
useCall()
One live call for a component. start makes a fresh call each time, the state follows it, and the call ends when the component goes away.
import { useCall } from "@daxov/react";
export function MyCall() {
const { state, start, end, toggleMute } = useCall();
const live = state.phase === "live";
return (
<div>
<button onClick={() => start(() => fetch("/api/calls", { method: "POST" }).then((r) => r.json()))}>
Talk to Alex
</button>
{live && <button onClick={toggleMute}>{state.muted ? "Unmute" : "Mute"}</button>}
{live && <button onClick={() => end()}>End</button>}
{state.error && <p role="alert">{state.error.message}</p>}
</div>
);
}| Returns | What it is |
|---|---|
state | The call's state (fields) |
call | The Call itself, for its events (call.on("transcript", …)); null before the first start |
start(source) | Starts a fresh call. Call it straight from a click: it opens the microphone first, then asks for the CallStart. Problems land in state.error; the promise doesn't reject for them |
end(reason?) | Hangs up |
setMuted(muted), toggleMute() | Mutes or unmutes |
useCall(options) takes the same options as new Call(). Pass its result to <Conversation call={…}> to keep the drop-in look but start the call from your own button.