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 ICE fails or the data channel closes (see reconnection)
CallsEach REST call becomes a promise, resolved with the call or rejected with a PhoneError; call events update the Call objects; an incoming call another session answers ends here with answered_elsewhere
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 (the browser's automatic gain is off: inputVolume is the only gain), 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 needs HTMLMediaElement.setSinkId, which some Safari versions lack: check phone.canChooseOutput.

On this page