Installations
npm install @telnyx/react-client
Developer Guide
Typescript
Yes
Module System
CommonJS
Min. Node Version
>=14.x
Node Version
14.21.3
NPM Version
6.14.18
Releases
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
Contributors
Unable to fetch Contributors
Languages
TypeScript (99.32%)
JavaScript (0.62%)
CSS (0.04%)
Shell (0.02%)
Love this project? Help keep it running — sponsor us today! 🚀
Developer
Download Statistics
Total Downloads
31,315
Last Day
122
Last Week
621
Last Month
2,509
Last Year
14,518
GitHub Statistics
41 Stars
660 Commits
19 Forks
10 Watching
25 Branches
19 Contributors
Bundle Size
2.37 kB
Minified
898.00 B
Minified + Gzipped
Package Meta Information
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
Total Downloads
Cumulative downloads
Total Downloads
31,315
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
Daily Downloads
Weekly Downloads
Monthly Downloads
Yearly Downloads
Peer Dependencies
3
Dev Dependencies
25
@telnyx/react-client
React wrapper for Telnyx Client
Install
1npm install --save @telnyx/react-client @telnyx/webrtc
Usage example
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}
Hooks
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}
Components
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}
Development
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
Contributing
License
![Empty State](/_next/static/media/empty.e5fae2e5.png)
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
- Info: project has a license file: LICENSE:0
- Info: FSF or OSI recognized license: MIT License: LICENSE:0
Reason
Found 19/30 approved changesets -- score normalized to 6
Reason
detected GitHub workflow tokens with excessive permissions
Details
- Warn: no topLevel permission defined: .github/workflows/draft-release.yml:1
- Warn: no topLevel permission defined: .github/workflows/publish-gh-pages.yml:1
- Warn: no topLevel permission defined: .github/workflows/publish-release.yml:1
- Warn: no topLevel permission defined: .github/workflows/update-changelog.yaml:1
- Warn: no topLevel permission defined: .github/workflows/webrtc-cdn-deploy.yml:1
- Warn: no topLevel permission defined: .github/workflows/webrtc-test-release.yml:1
- Info: no jobLevel write permissions found
Reason
no effort to earn an OpenSSF best practices badge detected
Reason
dependency not pinned by hash detected -- score normalized to 0
Details
- Warn: GitHub-owned GitHubAction not pinned by hash: .github/workflows/draft-release.yml:23: update your workflow using https://app.stepsecurity.io/secureworkflow/team-telnyx/webrtc/draft-release.yml/main?enable=pin
- Warn: GitHub-owned GitHubAction not pinned by hash: .github/workflows/draft-release.yml:36: update your workflow using https://app.stepsecurity.io/secureworkflow/team-telnyx/webrtc/draft-release.yml/main?enable=pin
- Warn: GitHub-owned GitHubAction not pinned by hash: .github/workflows/publish-gh-pages.yml:14: update your workflow using https://app.stepsecurity.io/secureworkflow/team-telnyx/webrtc/publish-gh-pages.yml/main?enable=pin
- Warn: GitHub-owned GitHubAction not pinned by hash: .github/workflows/publish-gh-pages.yml:17: update your workflow using https://app.stepsecurity.io/secureworkflow/team-telnyx/webrtc/publish-gh-pages.yml/main?enable=pin
- Warn: third-party GitHubAction not pinned by hash: .github/workflows/publish-gh-pages.yml:30: update your workflow using https://app.stepsecurity.io/secureworkflow/team-telnyx/webrtc/publish-gh-pages.yml/main?enable=pin
- Warn: GitHub-owned GitHubAction not pinned by hash: .github/workflows/publish-release.yml:26: update your workflow using https://app.stepsecurity.io/secureworkflow/team-telnyx/webrtc/publish-release.yml/main?enable=pin
- Warn: GitHub-owned GitHubAction not pinned by hash: .github/workflows/publish-release.yml:39: update your workflow using https://app.stepsecurity.io/secureworkflow/team-telnyx/webrtc/publish-release.yml/main?enable=pin
- Warn: third-party GitHubAction not pinned by hash: .github/workflows/publish-release.yml:63: update your workflow using https://app.stepsecurity.io/secureworkflow/team-telnyx/webrtc/publish-release.yml/main?enable=pin
- Warn: third-party GitHubAction not pinned by hash: .github/workflows/publish-release.yml:67: update your workflow using https://app.stepsecurity.io/secureworkflow/team-telnyx/webrtc/publish-release.yml/main?enable=pin
- Warn: GitHub-owned GitHubAction not pinned by hash: .github/workflows/publish-release.yml:82: update your workflow using https://app.stepsecurity.io/secureworkflow/team-telnyx/webrtc/publish-release.yml/main?enable=pin
- Warn: GitHub-owned GitHubAction not pinned by hash: .github/workflows/publish-release.yml:95: update your workflow using https://app.stepsecurity.io/secureworkflow/team-telnyx/webrtc/publish-release.yml/main?enable=pin
- Warn: GitHub-owned GitHubAction not pinned by hash: .github/workflows/update-changelog.yaml:13: update your workflow using https://app.stepsecurity.io/secureworkflow/team-telnyx/webrtc/update-changelog.yaml/main?enable=pin
- Warn: GitHub-owned GitHubAction not pinned by hash: .github/workflows/webrtc-cdn-deploy.yml:23: update your workflow using https://app.stepsecurity.io/secureworkflow/team-telnyx/webrtc/webrtc-cdn-deploy.yml/main?enable=pin
- Warn: GitHub-owned GitHubAction not pinned by hash: .github/workflows/webrtc-cdn-deploy.yml:35: update your workflow using https://app.stepsecurity.io/secureworkflow/team-telnyx/webrtc/webrtc-cdn-deploy.yml/main?enable=pin
- Warn: third-party GitHubAction not pinned by hash: .github/workflows/webrtc-cdn-deploy.yml:57: update your workflow using https://app.stepsecurity.io/secureworkflow/team-telnyx/webrtc/webrtc-cdn-deploy.yml/main?enable=pin
- Warn: GitHub-owned GitHubAction not pinned by hash: .github/workflows/webrtc-test-release.yml:17: update your workflow using https://app.stepsecurity.io/secureworkflow/team-telnyx/webrtc/webrtc-test-release.yml/main?enable=pin
- Warn: GitHub-owned GitHubAction not pinned by hash: .github/workflows/webrtc-test-release.yml:23: update your workflow using https://app.stepsecurity.io/secureworkflow/team-telnyx/webrtc/webrtc-test-release.yml/main?enable=pin
- Warn: GitHub-owned GitHubAction not pinned by hash: .github/workflows/webrtc-test-release.yml:45: update your workflow using https://app.stepsecurity.io/secureworkflow/team-telnyx/webrtc/webrtc-test-release.yml/main?enable=pin
- Warn: GitHub-owned GitHubAction not pinned by hash: .github/workflows/webrtc-test-release.yml:52: update your workflow using https://app.stepsecurity.io/secureworkflow/team-telnyx/webrtc/webrtc-test-release.yml/main?enable=pin
- Info: 0 out of 15 GitHub-owned GitHubAction dependencies pinned
- Info: 0 out of 4 third-party GitHubAction dependencies pinned
Reason
security policy file not detected
Details
- Warn: no security policy file detected
- Warn: no security file to analyze
- Warn: no security file to analyze
- Warn: no security file to analyze
Reason
project is not fuzzed
Details
- Warn: no fuzzer integrations found
Reason
SAST tool is not run on all commits -- score normalized to 0
Details
- Warn: 0 commits out of 19 are checked with a SAST tool
Reason
18 existing vulnerabilities detected
Details
- Warn: Project is vulnerable to: GHSA-grv7-fg5c-xmjg
- Warn: Project is vulnerable to: GHSA-3xgq-45jj-v275
- Warn: Project is vulnerable to: GHSA-78xj-cgh5-2h22
- Warn: Project is vulnerable to: GHSA-2p57-rm9w-gvfp
- Warn: Project is vulnerable to: GHSA-p6mc-m468-83gw
- Warn: Project is vulnerable to: GHSA-952p-6rrq-rcjv
- Warn: Project is vulnerable to: GHSA-mwcw-c2x4-8c55
- Warn: Project is vulnerable to: GHSA-3j8f-xvm3-ffx4
- Warn: Project is vulnerable to: GHSA-j9fq-vwqv-2fm2
- Warn: Project is vulnerable to: GHSA-pqw5-jmp5-px4v
- Warn: Project is vulnerable to: GHSA-7fh5-64p2-3v2j
- Warn: Project is vulnerable to: GHSA-p8p7-x288-28g6
- Warn: Project is vulnerable to: GHSA-gcx4-mw62-g8wm
- Warn: Project is vulnerable to: GHSA-c2qf-rxjj-qqgw
- Warn: Project is vulnerable to: GHSA-72xf-g2v4-qvf3
- Warn: Project is vulnerable to: GHSA-cchq-frgv-rjh5
- Warn: Project is vulnerable to: GHSA-g644-9gfx-q4q4
- Warn: Project is vulnerable to: GHSA-3h5v-q93c-6h6q
Score
4.4
/10
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