Skip to main content
This is the final step of the quickstart. With the server route from step two in place, connect the browser and start a conversation with your avatar.

Install the JavaScript SDK

In your Next.js project, install the SDK with your package manager:

Connect the browser

Add a server action that signs a start ticket. The browser calls it just before each start, so the ticket is always fresh:
In the browser, get a ticket, send it to your route, create an Anam client with the session token, 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. The MESSAGE_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. The component also cleans up after itself. When the session ends, the connection closes, or the component unmounts, it removes its event listeners and calls stopStreaming(), so the session and the microphone don’t outlive the page. If it unmounts while still connecting, it ends the new session as soon as it opens.

Run your first conversation

  1. Save the server action as app/actions.ts and the component as app/AvatarChat.tsx, and render <AvatarChat /> from a page such as app/page.tsx. The route reads your avatar and agent IDs from ANAM_AVATAR_ID and ELEVENLABS_AGENT_ID, so the component doesn’t need them.
  2. Start your development server with your project’s dev command, such as npm run dev. Open the page on localhost.
  3. Click Start and allow microphone access. The avatar video should appear and the button should change to Stop.
  4. 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.
  5. Click Stop to end the session. Click Start again to check that you can reconnect, then stop the session when you finish testing. If you navigate away during a session, the component ends it for you.
Quickstart complete. You now have a working ElevenLabs agent with an Anam avatar.
If the video or conversation does not start, follow Troubleshooting.

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.
For more on event handling, message history, and connection lifecycle, see the basic Next.js app recipe.

Next: Add Director Notes

Connect ElevenLabs audio tags to the avatar’s performance.
Last modified on November 20, 2026