@firstlogicmetalab/client
v1.5.0
Published
Voice and video calling for web, React and React Native. No dependencies.
Downloads
288
Maintainers
Readme
@firstlogicmetalab/client
Voice and video calling for web, React and React Native — no dependencies.
New to VACT? Create a free account at vact.online — ₹100 of calling credit to build with, no card required. Full guides and API reference: vact.online/docs.html.
npm install @firstlogicmetalab/clientEverything is plain HTTPS plus the WebRTC already in your runtime. There is no Firebase, no signalling library and no vendor account.
Calls need the camera/microphone. On the web the browser shows the permission
prompt automatically on the first getUserMedia; the page must be served over
HTTPS (or localhost) for that to work.
import { VactClient } from '@firstlogicmetalab/client';
const vact = new VactClient('vact_app_your_public_app_id');
// Ring on incoming calls. Set this before connecting.
vact.onIncomingCall = async (incoming) => {
if (confirm(`${incoming.callerName} is calling`)) {
const call = await incoming.accept();
document.querySelector('#remote').srcObject = call.remoteStream;
} else {
await incoming.decline();
}
};
// Your backend mints this one-time token; the App Secret stays on your server.
const { accessToken } = await (await fetch('/api/vact-token', {
method: 'POST', credentials: 'include',
})).json();
await vact.connect(accessToken);
// Place a call.
const call = await vact.call('user_42', { video: true });
document.querySelector('#local').srcObject = call.localStream;
document.querySelector('#remote').srcObject = call.remoteStream;
call.onState = (state) => console.log(state);React Native
Use the companion package
@firstlogicmetalab/react-native —
it wires this client to react-native-webrtc and adds a useVact hook, so you
don't register globals or add a UUID polyfill yourself.
npm install @firstlogicmetalab/react-native react-native-webrtcScreen sharing
On a video call, swap the camera for the screen (web/Electron only —
getDisplayMedia is unavailable on React Native):
await call.startScreenShare(); // camera → screen
await call.stopScreenShare(); // back to cameraMultiple ringing calls
onIncomingCall fires per call; onIncomingCalls(listener) gives the full
ringing set and an unsubscribe, handy for showing/clearing a call UI:
const stop = vact.onIncomingCalls((calls) => setRinging(calls));Sessions
A session lasts one hour by default. Handle onSessionExpired, or renew ahead
of sessionExpiresAt:
await vact.renew(await getFreshAccessToken());Full documentation: https://vact.online/docs.html
