For AI agents: a documentation index is available at the root level at /llms.txt and /llms-full.txt. Append /llms.txt to any URL for a page-level index, or .md for the markdown version of any page.
Log inSign up
Support
ReferenceGuidesClick-to-Call
ReferenceGuidesClick-to-Call
  • Core
    • Overview
  • SignalWire Client
    • Overview
    • Notifications
    • Client
      • Address Namespace
      • Chat Namespace
      • Conversation Namespace
    • Utility functions
  • Video
    • Overview
    • LocalOverlay
    • RoomSession
    • RoomSessionDevice
    • RoomSessionPlayback
    • RoomSessionRecording
    • RoomSessionScreenShare
    • RoomSessionStream
    • RoomDevice
    • RoomScreenShare
  • Chat
    • Overview
    • Client
    • ChatMember
    • ChatMemberEntity
    • ChatMessage
    • ChatMessageEntity
  • PubSub
    • Overview
    • Client
    • PubSubMessage
  • WebRTC
    • Overview
LogoLogoSignalWire Docs
Log inSign up
Support
On this page
  • Instantiation
  • Parameters
  • Example
  • Properties
  • Methods
  • Namespaces
  • Type aliases
  • IncomingCallHandlers
  • IncomingCallNotification
  • IncomingInvite
  • CallOptions
  • MediaStreamConstraints
  • CallFabricRoomSession
SignalWire Client

The SignalWire Client

|View as Markdown|Open in Claude|
Was this page helpful?
Edit this page
Previous

Address Namespace

Next
Built with

The SignalWire Client provides access to SignalWire’s services on the browser. It provides methods to handle incoming calls, dial to addresses, and register devices for notifications.

Instantiation

The SignalWire client is instantiated using the SignalWire function.

If you’re including the @signalwire/js dependency as a script in HTML, the SignalWire function is a property of the SignalWire global variable that the script sets:

1<script type="text/javascript" src="https://cdn.signalwire.com/@signalwire/js"></script>
2<script>
3 async function main() {
4 const client = await SignalWire.SignalWire({
5 token: "<TOKEN>",
6 });
7 }
8</script>

If you installed @signalwire/js from npm:

1import { SignalWire } from "@signalwire/js";
2
3async function main() {
4 const client = await SignalWire({
5 token: "<TOKEN>",
6 });
7}

For React or React Native projects, use the community library:

1import { useSignalWire } from "@signalwire-community/react";
2
3export default function App() {
4 const client = useSignalWire({
5 token: "<TOKEN>",
6 });
7}

Parameters

token
stringRequired

The access token for the subscriber.

rootElement
HTMLElement

The HTML container element where the SDK will display the video stream.

incomingCallHandlers
IncomingCallHandlers

Callback functions for when a call is received. See IncomingCallHandlers.

userVariables
Record<string, any toc={true}>

Arbitrary variables that are transparent to FreeSWITCH.

You can manage the DOM yourself by not specifying a rootElement here and using the buildVideoElement function instead.

Example

Vanilla JS
React (community)
1<html>
2 <body>
3 <script type="text/javascript" src="https://cdn.signalwire.com/@signalwire/js"></script>
4
5 <script>
6 async function main() {
7 const client = await SignalWire.SignalWire({
8 token: "<TOKEN>",
9 });
10
11 const conversations = await client.conversation.getConversations();
12 console.log(conversations);
13
14 const addresses = await client.address.getAddresses();
15 console.log(addresses);
16 }
17 main();
18 </script>
19 </body>
20</html>

Properties

httpHost
string

Returns the URL of the host that the client will use to make HTTP requests (like querying the list of addresses or conversations). Read-only.

1console.log(client.httpHost());
2// fabric.signalwire.com

Methods

dial

Dial to an address

online

Go online to receive call invites

offline

Go offline to stop receiving call invites

getSubscriberInfo

Get info about the current subscriber

connect

Connect the WebSocket client

disconnect

Disconnect the WebSocket client

updateToken

Update the auth token

Namespaces

Certain methods and properties are organized into namespaces for clarity. They can be accessed as follows:

1client.address.getAddresses();
2client.chat.getMessages();
3client.conversation.getConversations();
Address

Methods for working with addresses

Chat

Methods for chat functionality

Conversation

Methods for conversations

Type aliases

IncomingCallHandlers

Use this object to assign callback functions which get invoked when a call is received.

NameTypeRequired?Description
all(IncomingCallNotification) => voidOptionalSince push support has been removed, identical to websocket
websocket(IncomingCallNotification) => voidOptionalCallback for calls received via websocket (overrides all)

IncomingCallNotification

The object passed into the IncomingCallHandlers callback with the call description and controls.

NameTypeDescription
inviteobject-
invite.detailsIncomingInviteThe details of the invite.
invite.accept(CallOptions) => Promise<CallFabricRoomSession>Invoke this function to accept the incoming call
invite.reject() => Promise<void>Invoke this function to reject the incoming call

IncomingInvite

NameTypeDescription
source"websocket"
callIDstringUnique ID of the incoming call
sdpstringDeprecated
caller_id_namestringName of the caller
caller_id_numberstringID or number of the caller
callee_id_namestringName of the callee
callee_id_numberstringID or number of the callee
display_directionstringDirection of the call
nodeIdstringThe node from where the call was received

CallOptions

NameTypeRequired?Description
rootElementHTMLElementOptionalThe HTML container element where the SDK will display the video stream.
audioboolean | MediaTrackConstraintsOptionalMedia track constraints for audio. Passing true uses browser defaults, and false disables audio.
videoboolean | MediaTrackConstraintsOptionalMedia track constraints for video. Passing true uses browser defaults, and false disables video.
disableUdpIceServersbooleanOptionalDisables the ICE UDP transport policy.
userVariablesRecord<string, any>OptionalArbitrary variables that are transparent to FreeSWITCH.

MediaStreamConstraints

NameTypeRequired?Description
audioboolean | MediaTrackConstraintsOptionalMedia track constraints for audio. Passing true uses browser defaults, and false disables audio.
videoboolean | MediaTrackConstraintsOptionalMedia track constraints for video. Passing true uses browser defaults, and false disables video.
peerIdentitystringOptionalPeer identity.
preferCurrentTabbooleanOptionalWhether to prefer current tab for the call.

CallFabricRoomSession

Extends RoomSession.

NameTypeDescription
start() => voidStarts the call.
answerboolean | MediaTrackConstraintsAnswers the call (only works if the CallFabricRoomSession was a result of an incoming call).
hangup(id?) => voidEnds the ongoing call by default. If the id of an RTCPeer is passed, hangs up that RTCPeer.