{"id":15622466,"url":"https://github.com/ajb413/pubnub-js-webrtc","last_synced_at":"2025-08-31T15:05:07.780Z","repository":{"id":40950752,"uuid":"173669659","full_name":"ajb413/pubnub-js-webrtc","owner":"ajb413","description":null,"archived":false,"fork":false,"pushed_at":"2023-01-03T17:13:05.000Z","size":242,"stargazers_count":18,"open_issues_count":7,"forks_count":11,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-04-28T17:07:52.531Z","etag":null,"topics":["javascript","presence","pubnub","pubnub-webrtc","signaling-service","video-calls","video-chat","webrtc","webrtc-javascript-library","webrtc-phone","xirsys"],"latest_commit_sha":null,"homepage":"https://adambavosa.com/pubnub-js-webrtc/example/","language":"JavaScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/ajb413.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2019-03-04T03:48:51.000Z","updated_at":"2024-04-01T05:23:13.000Z","dependencies_parsed_at":"2023-02-01T08:01:55.305Z","dependency_job_id":null,"html_url":"https://github.com/ajb413/pubnub-js-webrtc","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ajb413%2Fpubnub-js-webrtc","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ajb413%2Fpubnub-js-webrtc/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ajb413%2Fpubnub-js-webrtc/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ajb413%2Fpubnub-js-webrtc/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/ajb413","download_url":"https://codeload.github.com/ajb413/pubnub-js-webrtc/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":251352605,"owners_count":21575863,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["javascript","presence","pubnub","pubnub-webrtc","signaling-service","video-calls","video-chat","webrtc","webrtc-javascript-library","webrtc-phone","xirsys"],"created_at":"2024-10-03T09:54:06.850Z","updated_at":"2025-04-28T17:08:06.409Z","avatar_url":"https://github.com/ajb413.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# JavaScript WebRTC Video Chat Package with PubNub\n\nAdds the ability to do 1-to-1 WebRTC audio/video calls with [PubNub](https://www.pubnub.com/?devrel_gh=pubnub-js-webrtc). The PubNub key set must have PubNub Presence enabled. The example folder app uses Xirsys to get TURN server access via a PubNub Function.\n\n[![WebRTC with PubNub Chat in JavaScript Screenshot](https://i.imgur.com/X0YULf5.png)](https://adambavosa.com/pubnub-js-webrtc/example/)\n\nFor education on WebRTC, and also a how-to for making your own app with this repository see these blog posts:\n- Part 1 [Integrating Video Calling In Chat With WebRTC And PubNub](https://www.pubnub.com/blog/integrating-video-calling-in-chat-with-webrtc-and-pubnub/?devrel_gh=pubnub-js-webrtc)\n- Part 2 [Implement Video Chat With Xirsys, WebRTC, And PubNub](https://www.pubnub.com/blog/xirsys-webrtc-and-pubnub-video-chat/?devrel_gh=pubnub-js-webrtc)\n\n## Initialization of the WebRTC Phone\n```js\nlet pubnub = new PubNub({\n    publishKey: 'your-publish-api-key-here',\n    subscribeKey: 'your-subscribe-api-key-here'\n});\n\n// set up all event handlers ...\n\n// WebRTC phone object configuration.\nlet config = {\n    rtcConfig,\n    ignoreNonTurn: false,\n    myStream: myAudioVideoStream,\n    onPeerStream,   // is required\n    onIncomingCall, // is required\n    onCallResponse, // is required\n    onDisconnect,   // is required\n    pubnub          // is required\n};\n\nwebRtcPhone = new WebRtcPhone(config);\n```\n\n## Items that are provided to the `WebRtcPhone` constructor via the `config` object\n```js\n// Standard WebRTC constructor config parameter (this data is for example purposes and will not work)\nlet rtcConfig = {\n    iceServers: [\n        {\n            urls: \"stun:stun.example.com\",\n            username: \"adamb@pubnub.com\", \n            credential: \"webrtcdemo\"\n        }, {\n            urls: [\"stun:stun.example.com\", \"stun:stun-1.example.com\"]\n        }\n    ]\n};\n\n// WebRTC phone object event for when the remote peer's video becomes available.\nconst onPeerStream = (webRTCTrackEvent) =\u003e {\n    console.log('Peer audio/video stream now available');\n    const peerStream = webRTCTrackEvent.streams[0];\n    window.peerStream = peerStream;\n    remoteVideo.srcObject = peerStream; // HTML \u003cvideo\u003e element\n};\n\n// WebRTC phone object event for when a remote peer attempts to call you.\nconst onIncomingCall = (fromUuid, callResponseCallback) =\u003e {\n    let username = 'Bob';\n    incomingCall(username).then((acceptedCall) =\u003e {\n        if (acceptedCall) {\n            // End an already open call before opening a new one\n            webRtcPhone.disconnect();\n            // Update your UI for showing peer video feed\n        }\n\n        callResponseCallback({ acceptedCall });\n    });\n};\n\n// WebRTC phone object event for when the remote peer responds to your call request.\nconst onCallResponse = (acceptedCall) =\u003e {\n    console.log('Call response: ', acceptedCall ? 'accepted' : 'rejected');\n    if (acceptedCall) {\n        // Update your UI for showing peer video feed\n    }\n};\n\n// WebRTC phone object event for when a call disconnects or timeouts.\nconst onDisconnect = () =\u003e {\n    console.log('Call disconnected');\n    // Update your UI for hiding peer video feed\n};\n```\n\n## Send a call request to another user\n```js\nwebRtcPhone.callUser(\"Alice\", {\n    myStream: myAudioVideoStream // Get this stream with `navigator.mediaDevices.getUserMedia()`\n});\n```\n\n## Frequently Asked Questions (FAQ) about the PubNub JS WebRTC Package\n\n### What is WebRTC?\nWebRTC is a free and open source project that enables web browsers and mobile devices to provide a simple real-time communication API. Please read this [PubNub blog](https://www.pubnub.com/blog/integrating-video-calling-in-chat-with-webrtc-and-pubnub/?devrel_gh=pubnub-js-webrtc) to learn more about WebRTC and how to implement the code in this repository.\n\n### What is PubNub? Why is PubNub relevant to WebRTC?\n[PubNub](https://www.pubnub.com/?devrel_gh=pubnub-js-webrtc) is a global Data Stream Network (DSN) and realtime network-as-a-service. PubNub's primary product is a realtime publish/subscribe messaging API built on a global data stream network which is made up of a replicated network with multiple points of presence around the world.\n\nPubNub is a low cost, easy to use, infrastructure API that can be implemented rapidly as a WebRTC signaling service. The signaling service is responsible for delivering messages to WebRTC peer clients. See the next question for the specific signals that PubNub's publish/subscribe API handles.\n\n### Does PubNub stream audio or video data?\nNo. PubNub pairs very well with WebRTC as a signaling service. This means that PubNub signals events from client to client using the Pub/Sub messaging over TCP. These events include:\n- I, User A, would like to call you, User B\n- User A is currently trying to call you, User B\n- I, User B, accept your call User A\n- I, User B, reject your call User A\n- I, User B, would like to end our call User A\n- I, User A, would like to end our call User B\n- Text instant messaging like in Slack, Google Hangouts, Skype, Facebook Messenger, etc.\n\n### Is this package officially part of PubNub?\nNo. It is an open source project that is community supported. If you want to report a bug, do so on the [GitHub Issues page](https://github.com/ajb413/pubnub-js-webrtc/issues).\n\n### Can I make a group call with more than 2 participants?\nGroup calling is possible to develop with WebRTC and PubNub, however, the current PubNub WebRTC package can connect only 2 users in a private call. The community may develop this feature in the future but there are no plans for development to date.\n\n### I found a bug in the package. Where do I report it?\nThe PubNub WebRTC package is an [open source](https://github.com/ajb413/pubnub-js-webrtc/blob/master/LICENSE), community supported project. This means that the best place to report bugs is on the [GitHub Issues page](https://github.com/ajb413/pubnub-js-webrtc/issues) in for the code repository. The community will tackle the bug fix at will, so there is no guarantee that a fix will be made. If you wish to provide a code fix, fork the GitHub repository to your GitHub account, push fixes, and make a pull request ([process documented on GitHub](https://help.github.com/articles/creating-a-pull-request-from-a-fork/)).\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fajb413%2Fpubnub-js-webrtc","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fajb413%2Fpubnub-js-webrtc","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fajb413%2Fpubnub-js-webrtc/lists"}