WebSocket Transport Layer
The SDK defaults to WebRTC for real-time voice conversations. In environments where WebRTC is unavailable, you can opt in to a WebSocket-based transport instead.
When to use WebSocket transport
Situation
Recommendation
Setup
React
// 1. Register the transport — must be imported before connect() is called
import '@convai/web-sdk/vanilla/websocket';
import { useConvaiClient, ConvaiWidget } from '@convai/web-sdk/react';
export default function App() {
const client = useConvaiClient({
apiKey: '...',
characterId: '...',
transport: 'websocket',
});
return <ConvaiWidget convaiClient={client} />;
}Vanilla JS
Bundle isolation
Feature comparison
Feature
WebRTC (default)
WebSocket
Microphone behaviour
API reference
Config
Field
Type
Default
Description
Static method
Last updated
Was this helpful?