Getting Started with ApiRTC React Hooks
How to build a video chat app with ApiRTC ReactJS hooks
Last updated
How to build a video chat app with ApiRTC ReactJS hooks
Last updated
You were thinking ApiRTC.js was an easy thing to play with? Gain 10x development time by using the ApiRTC React Hooks Library, and integrate video communication in your app that reach enterprise-grade needs: stability, quality of service and integration into an existing ecosystem.
A hook is basically a module that makes state management of an object easier and well integrated within the ReactJS rendering lifecycle. Although High-Order Components and component.props can implement the same logic, it needs a lot more components and props to be managed.
Hooks simplifies the use of functional logic into your app.
You may know the useState()
standard hook that enables to make a variable stateful and integrated into the ReactJS lifecycle.
ApiRTC ReactJS Hooks enables any developer to:
Grab the local devices streams, display the local video and publish them into a Conversation
Listen to the remote streams and display them onto a web page
Apply noise reduction on audio and blur or image in the background of the video stream
Manage groups of connected participants (presence management)
Apply moderation functions in the Conversation
Send & Receive chat messages
You need a Linux environment with the following installed:
NodeJS in its latest version
NPM in its latest version
Create a new ReactJS-enabled web app by using create-react-app
command:
Use NPM to install ApiRTC needed library:
This app will simply connect to a Conversation named conversationName
and will share the video streams across the participants thanks to 4 hooks:
useSession
: connect to the ApiRTC service
useCameraStream
: grab the local video stream coming from the camera
useConversation
: join a Conversation and get the always-updated state of it
useConversationStreams
: get an updated list of Streams flowing through the Conversation
Additionnaly, we will use the VideoStream
component that makes video display easier.
Replace the /src/App.js file content by the following:
Continue to explore ApiRTC:
Understand the ApiRTC Architecture
ApiRTC implements the video communication lifecycle into Hooks modules, gathered into one library available as the .
Create or join a
See the ApiRTC React library's for detailed information on available hooks and components.
The best way to get you machine set up is to for both nodeJS and NPM:
You are all set for building your first ReactJS-based video communication app, well done!
Replace INSERT_YOUR_API_KEY_HERE
by your actual API Key. You can have one (free) on .
The source code of this getting started article is available on the dedicated repository, in the /react-hooks-basic
folder.
Get to know the
Read the of the ApiRTC React Lib to get more details on what is possible