JS Client Example
This example demonstrates a simple starting point for using the Nabto WebRTC JavaScript Client SDK. For a full demo see the Web Demo. For details on using the SDK, see this guide.
Obtaining the source
The example code is found on the SDK git repo.
Clone the repo and go to the example directory:
$ git clone https://github.com/nabto/nabto-webrtc-sdk-js.git
$ cd nabto-webrtc-sdk-js/examples/very-simple-client-example
Running the example
Since this is a client example, it must first have a device to connect to and receive a video feed from. To start a Nabto WebRTC device, follow the device mode section of the Web Demo.
When starting the device a Product ID, a Device ID, and a Shared Secret was used. These will be needed next.
From the example directory, open the main.js
file. Enter the Product ID, Device ID, and Shared Secret in place of the ...
strings. The code should look similar to this:
const productId = "wp-zzjhk3jm";
const deviceId = "wd-fab3mbcfvio73g3u";
const sharedSecret = "d4ff5ecd8f21ed40c889cd350a524f9945a374b5e962dbf0bc1eeec71ee5dc1b";
Now, from the example directory, install the NPM dependencies and run the example:
$ npm install
$ npm run vite
Finally, open http://localhost:5173
in a browser to see the video feed from the device.