Gathering detailed insights and metrics for @telnyx/react-client
Gathering detailed insights and metrics for @telnyx/react-client
npm install @telnyx/react-client
Typescript
Module System
Min. Node Version
Node Version
NPM Version
webrtc@2.22.5
Published on 17 Jan 2025
webrtc@2.22.4
Published on 14 Jan 2025
webrtc@2.22.3
Published on 03 Dec 2024
webrtc@2.22.2
Published on 14 Nov 2024
webrtc@2.22.1
Published on 01 Nov 2024
webrtc@2.22.0
Published on 28 Oct 2024
TypeScript (99.32%)
JavaScript (0.62%)
CSS (0.04%)
Shell (0.02%)
Love this project? Help keep it running — sponsor us today! 🚀
Total Downloads
31,315
Last Day
122
Last Week
621
Last Month
2,509
Last Year
14,518
41 Stars
660 Commits
19 Forks
10 Watching
25 Branches
19 Contributors
Minified
Minified + Gzipped
Latest Version
1.0.2
Package Id
@telnyx/react-client@1.0.2
Unpacked Size
63.29 kB
Size
10.79 kB
File Count
18
NPM Version
6.14.18
Node Version
14.21.3
Publised On
17 Nov 2023
Cumulative downloads
Total Downloads
Last day
20.8%
122
Compared to previous day
Last week
-4.6%
621
Compared to previous week
Last month
19.9%
2,509
Compared to previous month
Last year
125.4%
14,518
Compared to previous year
3
25
React wrapper for Telnyx Client
1npm install --save @telnyx/react-client @telnyx/webrtc
1// App.jsx 2import { TelnyxRTCProvider } from '@telnyx/react-client'; 3 4function App() { 5 const credential = { 6 login_token: 'mytoken', 7 }; 8 9 return ( 10 <TelnyxRTCProvider credential={credential}> 11 <Phone /> 12 </TelnyxRTCProvider> 13 ); 14}
1// Phone.jsx 2import { useNotification, Audio } from '@telnyx/react-client'; 3 4function Phone() { 5 const notification = useNotification(); 6 const activeCall = notification && notification.call; 7 8 return ( 9 <div> 10 {activeCall && 11 activeCall.state === 'ringing' && 12 'You have an incoming call.'} 13 14 <Audio stream={activeCall && activeCall.remoteStream} /> 15 </div> 16 ); 17}
useCallbacks
1import { useCallbacks } from '@telnyx/react-client'; 2 3function Phone() { 4 useCallbacks({ 5 onReady: () => console.log('client ready'), 6 onError: () => console.log('client registration error'), 7 onSocketError: () => console.log('client socket error'), 8 onSocketClose: () => console.log('client disconnected'), 9 onNotification: (x) => console.log('received notification:', x), 10 }); 11 12 // ... 13}
useTelnyxRTC
If you need more fine-tuned control over TelnyxRTC, you also have access to useTelnyxRTC
directly.
1import { useTelnyxRTC } from '@telnyx/react-client'; 2 3function Phone() { 4 const client = useTelnyxRTC({ login_token: 'mytoken' }); 5 6 client.on('telnyx.ready', () => { 7 console.log('client ready'); 8 }); 9 10 // ... 11}
Take care to use this hook only once in your application. For most cases, we recommend you use TelnyxRTCContext/TelnyxRTCProvider instead of this hook directly. This ensures that you only have one Telnyx client instance running at a time.
useContext
with TelnyxRTCContext
You can retrieve the current TelnyxRTC context value by using React's useContext
hook, as an alternative to TelnyxRTCContext.Consumer.
1import React, { useContext } from 'react'; 2import { TelnyxRTCContext } from '@telnyx/react-client'; 3 4function Phone() { 5 const client = useContext(TelnyxRTCContext); 6 7 client.on('telnyx.ready', () => { 8 console.log('client ready'); 9 }); 10 11 // ... 12}
TelnyxRTCContextProvider
1import { TelnyxRTCProvider } from '@telnyx/react-client'; 2 3function App() { 4 const credential = { 5 // You can either use your On-Demand Credential token 6 // or your Telnyx SIP username and password 7 // login_token: 'mytoken', 8 login: 'myusername', 9 password: 'mypassword', 10 }; 11 12 const options = { 13 ringtoneFile: 'https://example.com/sounds/incoming_call.mp3', 14 ringbackFile: 'https://example.com/sounds/ringback_tone.mp3', 15 }; 16 17 return ( 18 <TelnyxRTCProvider credential={credential} options={options}> 19 <Phone /> 20 </TelnyxRTCProvider> 21 ); 22}
TelnyxRTCContext.Consumer
1import { TelnyxRTCContext } from '@telnyx/react-client'; 2 3function PhoneWrapper() { 4 return ( 5 <TelnyxRTCContext.Consumer> 6 {(context) => <Phone client={context} />} 7 </TelnyxRTCContext.Consumer> 8 ); 9}
Audio
1import { Audio } from '@telnyx/react-client'; 2 3function Phone({ activeCall }) { 4 return ( 5 <div> 6 <Audio stream={activeCall.remoteStream} /> 7 </div> 8 ); 9}
Video
1import { Video } from '@telnyx/react-client'; 2 3function VideoConference({ activeCall }) { 4 return ( 5 <div> 6 <Video stream={activeCall.localStream} muted /> 7 <Video stream={activeCall.remoteStream} /> 8 </div> 9 ); 10}
Install dependencies:
1yarn install 2yarn start 3yarn link 4 5# in another tab: 6git clone https://github.com/team-telnyx/webrtc-examples/tree/main/react-client/react-app 7 8# fill in .env 9yarn install 10yarn link @telnyx/react-client 11yarn start
No vulnerabilities found.
Reason
14 commit(s) and 4 issue activity found in the last 90 days -- score normalized to 10
Reason
no binaries found in the repo
Reason
no dangerous workflow patterns detected
Reason
license file detected
Details
Reason
Found 19/30 approved changesets -- score normalized to 6
Reason
detected GitHub workflow tokens with excessive permissions
Details
Reason
no effort to earn an OpenSSF best practices badge detected
Reason
dependency not pinned by hash detected -- score normalized to 0
Details
Reason
security policy file not detected
Details
Reason
project is not fuzzed
Details
Reason
SAST tool is not run on all commits -- score normalized to 0
Details
Reason
18 existing vulnerabilities detected
Details
Score
Last Scanned on 2025-01-27
The Open Source Security Foundation is a cross-industry collaboration to improve the security of open source software (OSS). The Scorecard provides security health metrics for open source projects.
Learn More