Skip to main content

Framework Integration

The Telnyx WebRTC JS SDK works with any JavaScript framework. This guide covers integration patterns for popular frameworks.

React

Install

Using the React wrapper

The @telnyx/react-client package provides hooks and context providers:

Using the SDK directly

If you prefer to use the SDK without the React wrapper:
Always disconnect the client on component unmount to prevent zombie WebSocket connections.

Next.js

Next.js requires special handling because the SDK uses browser APIs (WebSocket, RTCPeerConnection) that don’t exist on the server.

Dynamic import

Client component (App Router)


Vue

Composable

Component


Angular

Service


General Patterns

Token fetching

All frameworks should fetch JWT tokens from a backend endpoint:

Audio element management

The SDK auto-creates audio elements, but in some frameworks you may want to manage them yourself:
Or after the call is active:

Per-call media elements (concurrent calls)

Starting with SDK v2.27.4, you can assign a distinct remoteElement (and localElement) per call so concurrent calls in a single client session attach to independent <audio>/<video> elements with independent playout lifecycles. Hanging up one call never tears down another call’s element. Outbound calls — pass remoteElement at call creation:
Inbound calls — pass remoteElement when answering:
Omitting the per-call params keeps the session-level client.remoteElement as the fallback default — backward compatible with existing single-call integrations. If two calls share the same remoteElement, the SDK emits a SHARED_REMOTE_ELEMENT_OVERWRITE warning (33011) when the second call overwrites the first call’s MediaStream. Assign distinct elements to avoid this. See Manage Multiple Calls for the full concurrent-call guide.

Cleanup

Always clean up on unmount/unload:

See Also