Install the JavaScript SDK
In your Next.js project, install the SDK with your package manager:Connect the browser
Request the session token, create an Anam client, and attach its stream to your video element:streamToVideoElement() starts microphone capture and renders the avatar’s video and audio in the element with the matching ID.
Working component example
Below is a React component with connection lifecycle and a streaming transcript. TheMESSAGE_STREAM_EVENT_RECEIVED event fires for each chunk of text from both the user and the agent. Accumulate chunks by message ID to build the full transcript.
Run your first conversation
- Save the component above as
AvatarChat.tsxand render it on a page in your Next.js app. Pass your Cara 4 avatar ID asavatarIdand the ElevenLabs agent ID from step one asagentId. - Start your development server with your project’s dev command, such as
npm run dev. Open the page on localhost. - Click Start and allow microphone access. The avatar video should appear and the button should change to Stop.
- Speak to the agent. Confirm that you hear its reply, see the avatar speaking in sync, and see both sides of the conversation in the transcript.
- Click Stop to end the session. Click Start again to check that you can reconnect, then stop the session when you finish testing.
Quickstart complete. You now have a working ElevenLabs agent with an Anam avatar.
Upgrade your avatar
Your avatar session is running. Build on it with expressive performance, personalised conversations, and actions in your app:- Director Notes: add expressions that follow ElevenLabs audio tags.
- Session customisation: pass user-specific variables, override settings, or attach a user ID.
- Client tools: let the agent trigger actions in your browser and receive the results.
Next: Add Director Notes
Connect ElevenLabs audio tags to the avatar’s performance.

