Adding real time communication to your web app is made easy with the Quickblox JavaScript SDK and JavaScript code samples. We’ve created an entire toolkit so that you can save time and money by effortlessly adding chat and video calling features to any web or mobile app. What’s more, our code samples and SDKs are free to use.
Below is a step-by-step tutorial outlining how to download and run our JavaScript code samples for chat and WebRTC video conferencing, so that you can start building today.
Let’s go!
The first thing you need to do is download the sample, for this you may need git.
If you don’t have git, you can find instructions for installing it here Git Guides – install git. If you don’t want to install git – you can just download the archive from the git repository.
Download using git:
git clone git@github.com:QuickBlox/quickblox-javascript-sdk.git
Download the archive without git:
Follow the link GitHub – QuickBlox/quickblox-javascript-sdk: JavaScript SDK of QuickBlox cloud backend platform, press the green “Code” button and select “Download ZIP”
Then unpack the archive.
In order to run samples we need to have application credentials. To create a QuickBlox application follow the steps below:
To run web server we will need npm
installed, if you don’t have it see Downloading and installing Node.js and npm | npm Docs.
We have completed our preparations, now let’s move on to launching the samples.
To run a code sample follow the steps below:
samples/chat/js/QBconfig.js
with appId
, authKey
, authSecret
and accountKey
obtained at the “Application credentials” step above:var QBconfig = { credentials: { appId: '', authKey: '', authSecret: '', accountKey: '' } }
More details can be found here Quick Start | JavaScript SDK | QuickBlox.
To run a code sample follow the steps below:
samples/webrtc/config.js
with appId
, authKey
, authSecret
and accountKey
obtained at the “Application credentials” step above:const creds = { appId: '', authKey: '', authSecret: '', accountKey: '' };
More details can be found here Quick Start | JavaScript SDK | QuickBlox.
https
. Sample will be available at https://localhost:8080/samples/webrtc.To run a code sample follow the steps below:
samples/angular-chat/src/app/QBconfig.ts
with appId
, authKey
, authSecret
and accountKey
obtained at the “Application credentials” step above:export const QBconfig = { credentials: { appId: '', authKey: '', authSecret: '', accountKey: '' } };
angular-chat
folder from unpacked archive and run following command:npm install
npm start
Sample will be available on http://localhost:4200.
Or if you want to enable ssl:
npm start -- --ssl
Sample will be available on http://localhost:4200.
To run the video conference code sample, follow the steps below:
samples/video_conferencing/js/config/apps.js
with appId
, authKey
, authSecret
and accountKey
obtained at the “Application credentials” step above:var creds = { appId: '', authKey: '', authSecret: '', accountKey: '' };
https
. The site will be available on https://127.0.0.1:8080/samples/video_conferencing
, https://localhost:8080/samples/video_conferencing
and https://your_ip:8080/samples/video_conferencing
(where your_ip is the IP address of your computer in local network).https://localhost:8080/samples/video_conferencing?server=conferencing_server.
Additional details about how to obtain conferencing server endpoint and more can be found here Video Conference | JavaScript SDK | QuickBlox.
Open terminal (AKA “command prompt” on Windows), navigate to folder from unpacked archive and run server from current directory using the following command:
npx http-server .
The site will be available on http://127.0.0.1:8080, http://localhost:8080, http://your_ip:8080 (where your_ip is the IP address of your computer in the local network).
To run web server with SSL/TLS enabled will require an SSL certificate. See section below on how to create one if you don’t have one already.
To run web server over https
open terminal (AKA “command prompt” on Windows), navigate to folder from unpacked archive and run the following command:
npx http-server -S -C cert.pem .
The site will be available on http://127.0.0.1:8080/, https://localhost:8080, https://your_ip:8080 (where your_ip is the IP address of your computer in local network).
In order to allow web-browsers to access the audio and video input devices we need an SSL certificate to enable a secure connection (HTTPS
).
To check if you have openssl
installed use following command:
openssl version
If OpenSSL is installed already – proceed to “Generate certificate”.
If you’re getting an error saying that openssl
was not found – proceed with installation steps according to the instructions for your platform:
Install system specific openssl from this link.
Open command prompt and execute the following commands:
set OPENSSL_CONF=C:\OpenSSL-Win64\bin\openssl.cfg set Path=%Path%;C:\OpenSSL-Win64\bin
This will set environment variables for current session only.
Assuming you have homebrew installed:
brew install openssl
sudo apt install openssl
To generate key and cert files with OpenSSL use the following command:
openssl req -newkey rsa:2048 -new -nodes -x509 -days 3650 -keyout key.pem -out cert.pem
QuickBlox offers a robust and feature-rich Javascript SDK so that you can effortlessly add real time communication to any web app. Check out our detailed documentation to learn more.
For technical queries about using our SDK or recommendations for our product or documentation please submit a ticket to our support team.
Contact us if you want to learn more about how QuickBlox can support your communication needs.