06 Line
Browser SDK

createPhone

Create the phone that holds the connection, the audio and the calls of one page.

import { createPhone } from '@06line/sdk-browser';

const phone = createPhone({ getEphemeralKey: () => fetch('/api/06line-key', { method: 'POST' }).then((r) => r.json()) });

Returns a Phone. Create one per page: it opens a single WebRTC session and handles one call at a time.

Options

Prop

Type

What it does for you

ConcernHandled by the SDK
KeysFetches an ephemeral key at start and refreshes it before it expires
WebRTC sessionBuilds the offer with the ICE servers, opens the session, listens to its data channel, opens a new session when the network changes or ICE fails
CallsEach REST call becomes a promise, resolved with the call or rejected with a PhoneError; call events update the Call objects
Devices and volumesMicrophone and speaker chosen per call, changeable mid-call; input gain and playback volume from 0 to 2
MicrophonegetUserMedia with echo cancellation and noise suppression, or your own MediaStream; permission errors
AudioWebRTC with G.711: the browser handles jitter and lost packets; the SDK adds input gain, a soft limiter and playback volume
Call controlsMute, input and output levels for a meter

Browser support

Chrome, Edge, Firefox and Safari, current versions. Speaker choice is not available in Safari.

On this page