Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings
This repository was archived by the owner on Sep 23, 2025. It is now read-only.

layercodedev/example-frontend-react

Open more actions menu

Repository files navigation

Layercode Voice Agent React Example

This open source project demonstrates how to build a real-time voice agent using Layercode Voice Agents, with a React frontend (Vite + TypeScript).

Read the companion guides:

Features

  • Browser-based Voice Interaction: Users can speak to the agent directly from their browser.

How It Works

  1. Frontend:
    Uses @layercode/react-sdk to connect the browser's microphone and speaker to a Layercode voice agent. Connections must be authenticated with a client session key, which is generated by an /api/authorize route on your backend. The React SDK handles calling this route for you.

  2. Transcription & Webhook:
    Layercode transcribes user speech. For each complete message, it sends a webhook containing the transcribed text to your backend (see backend guide).

  3. Backend & Streaming:
    Your backend receives the transcription, generates a response using an LLM, and streams the response back to Layercode, which converts it to speech and plays it in the browser in real time.

Getting Started

Note: Layercode needs to send a webhook to your backend to generate agent responses. If you're running the backend locally, you'll need to set up a tunnel to your localhost. See the backend guide for details.

  1. Clone this repository.
  2. Install dependencies with npm install.
  3. Run the development server with npm run dev.
  4. Open http://localhost:5173 in your browser and start speaking to your voice agent!

Extra features

Push-to-talk mode

Layercode supports multiple turn-taking modes which are configured in the Transcriber settings of your voice agent in the Layercode dashboard. By default this example uses automated turn taking (which is the default for voice agents).

Push-to-talk is an alternative mode, where the user must hold the button down to speak. To enable this, go to the Transcriber settings of your voice agent in the Layercode dashboard and set the Turn Taking Mode to "Push-to-talk".

Then edit src/App.tsx and change the VoiceAgent component to use the VoiceAgentPushToTalk component. Now the user's speech will only be transcribed when the button is held down (or spacebar is pressed).

License

MIT

About

No description, website, or topics provided.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Contributors 2

  •  
  •  
Morty Proxy This is a proxified and sanitized view of the page, visit original site.