This tutorial will guide you through creating a web client that can interact with a ElevenLabs agent. You’ll learn how to implement real-time voice conversations, allowing users to speak with an AI agent that can listen, understand, and respond naturally using voice synthesis.
npm installed on your local system.Looking for a complete example? Check out our Next.js demo on GitHub.

This authentication step is only required for private agents. If you’re using a public agent, you
can skip this section and directly use the agentId in the startSession call.
If you’re using a private agent that requires authentication, you’ll need to generate a signed URL from your server. This section explains how to set this up.
Create a .env.local file in your project root:
.env.local to your .gitignore file to prevent accidentally committing sensitive credentials to version control.Create a new file app/api/get-signed-url/route.ts:
Modify your conversation.tsx to fetch and use the signed URL:
Signed URLs expire after a short period. However, any conversations initiated before expiration will continue uninterrupted. In a production environment, implement proper error handling and URL refresh logic for starting new conversations.
Now that you have a basic implementation, you can:
For more advanced features and customization options, check out the @elevenlabs/react package.