How can i get agentState like (useVoiceAssistant) ...
# ask-ai
a
How can i get agentState like (useVoiceAssistant) but with react native?
t
Thanks for reaching out, bogdanmelnikbo. I'm an AI assistant and I'm here to help. Give me a moment while I research this topic.
Hey there! You can easily grab the
agentState
in React Native by using the
useVoiceAssistant
hook from
@livekit/components-react
. Check out this example:
Copy code
import { useVoiceAssistant, type AgentState } from '@livekit/components-react';

function YourComponent() {
  const { state: agentState } = useVoiceAssistant();
  
  return (
    // Use agentState in your React Native component
  );
}
Just so you know, the
agentState
can be one of these: 'disconnected', 'connecting', 'initializing', 'listening', 'thinking', or 'speaking'. Hope this helps! Sources: src/hooks.ts | AI voice agents | LiveKit Docs
a
What is the equivalent of RoomAudioRenderer for React Native? How can I mute/unmute?
t
Hey there! Could you share a bit more about how you’re planning to use muting and unmuting in React Native? Are you trying to control the microphone, the speaker, or maybe both? Knowing this will really help me suggest the best solution for you. Sources: Audio rendering with React Components | LiveKit Docs | example/src/RoomControls.tsx