npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2026 – Pkg Stats / Ryan Hefner

@sayvona/voice

v0.1.0

Published

Browser calling for Sayvona: a headless WebRTC phone your web app drives with events and methods, signed in with short-lived access tokens. React hook included.

Readme

@sayvona/voice

Browser calling for Sayvona. A headless WebRTC phone your web app drives with events and methods: make and take real phone calls from a page, with no plugin and no desk phone. A React hook is included at @sayvona/voice/react.

npm install @sayvona/voice

Quickstart (5 minutes)

1. Your server mints a token for the signed-in user with @sayvona/node and your API key:

// server  -  npm install @sayvona/node express
import { Sayvona } from '@sayvona/node';
const sayvona = new Sayvona();            // reads SAYVONA_API_KEY

app.get('/voice-token', async (req, res) => {
  const { token } = await sayvona.voice.tokens.create({ agent_id: req.user.agentId });
  res.json({ token });
});

2. The page connects with it and calls:

import { createVoiceClient } from '@sayvona/voice';

const voice = createVoiceClient({
  // Called at connect and again before the session lapses; fetch a fresh one each time.
  getAccessToken: () => fetch('/voice-token').then(r => r.json()).then(j => j.token),
});

voice.on('registered',    () => console.log('Ready'));
voice.on('incoming',      call => confirm(`Answer ${call.number}?`) && voice.answer(call.id));
voice.on('callConfirmed', call => console.log('Talking to', call.number));
voice.on('callEnded',     ({ id }) => console.log('Call ended', id));

await voice.connect();
voice.call('+254712345678');

The page needs HTTPS (or localhost) and the user's permission to use the microphone. Audio plays by itself; remoteStream hands you the stream if you want to render it.

React

import { useVoiceClient } from '@sayvona/voice/react';

function Phone() {
  const { status, incoming, calls, client } = useVoiceClient({
    getAccessToken: () => fetch('/voice-token').then(r => r.json()).then(j => j.token),
  });
  if (status !== 'registered') return <span>Connecting…</span>;
  if (incoming) return <button onClick={() => client.answer(incoming.id)}>Answer {incoming.number}</button>;
  return <button onClick={() => client.call('+254712345678')}>Call</button>;
}

The hook connects on mount and disconnects on unmount. react 18 or later is an optional peer dependency.

Methods and events

connect(), disconnect(), isReady(), call(number), answer(id), hangup(id), hold(id), unhold(id), mute(id), unmute(id), dtmf(id, digits), getCalls().

Events (voice.on(name, handler)): registered, registrationFailed, disconnected, incoming, callStarted, callConfirmed, callEnded, remoteStream.

How the session works

connect() trades the token for a phone login made for this session alone. It rings together with the person's other phones and its calls carry their caller ID. Before it lapses the SDK calls getAccessToken() again and renews it; disconnect() ends it at once. If you stop issuing tokens, the session is ended soon after the last one expires. Up to three sessions per person; a fourth replaces the oldest.

With an access token, voice.server (transfer, park, presence) is not available yet and throws.

Notes

  • ESM only. Importing it during server-side rendering is safe: nothing touches the DOM until connect().
  • apiBaseUrl defaults to https://api.sayvona.com.

Licensed MIT.