While writing a series on how to control a web camera using an Arduino and WebRTC, I stumbled upon the need for a NodeJS implementation of WebRTC compatible with PubNub.

On my client I was using PubNub’s webrtc-sdk, so the path of least resistance was to take that same implementation and port it to work with NodeJS.

What I ended up with is the following package:


It is available through NPM and using it in your NodeJS projects is as simple as installing:

$ npm install --save node-pubnub-webrtc

And implementing:

var phone = require('node-pubnub-webrtc')({
  number        : 'pubduino.server',
  publish_key   : PUBLISH_KEY,
  subscribe_key : SUBSCRIBE_KEY,
  ssl           : true

  console.log('user connected');

phone.message(function(session, message){
  console.log('message received');

It should be noted that this implementation was built mainly to harness the RTCDataChannel, so if you’re looking to implement video and audio streams you’d need to find a way to shim the media streams to the PHONE object.

Happy coding!

Recent Blog Posts