Using Whereby's Web Component & Pre-built UI
The Web Component offering in our SDK allows you to leverage the thoughtfully designed, pre-built Whereby interface and user experience we've developed over the last 10+ years.
Below are a few examples of how you can use some of the client events and commands that can be sent to a room. We have information on how to get started and install, but for a full document about events, attributes, and commands you can view our Web Component Reference documentation.
Web Component ReferenceInstallation
When using React or a bundler like Webpack, Rollup, Parcel, etc. you can install the Whereby Browser SDK in your project using npm:
You can then import it as follows:
And embed your room using our <whereby-embed>
web component:
You can use a hostRoomUrl
instead of the roomUrl
, if you want to give the user host privileges
If you aren't using a bundler or a library containing a bundler you can access the component code directly from our CDN using a simple Script tag in your site
Listening to events
You can listen for events on the <whereby-embed>
component. Here are a few examples how the events might be useful, but there are lots of creative ways these might be useful! Let us know in an email or our discord how you've implemented these.
leave
When a user leaves the room, you can redirect them to a page of your choosing
participantupdate
Keep track of the number of participants in a room. Once a room has reached its capacity (200 participants), you can swap the room source URL to a viewerRoomUrl for additional capacity.
A few other ideas:
Display an in app greeting banner whenever there is a new
participant_join
eventDisplay an in app message directing users to certain support documentation whenever they accidentally
deny_device_permission
Make a log for support or success teams if a user frequently experiences
connection_status_change
errors so they can proactively reach out and investigate connection issues
Sending commands
For this feature to work, you must add the origin of your application to the "Allowed domains" section on your Whereby dashboard. If not present, the following methods will not function.
The <whereby-embed>
web component exposes a set of methods your application can invoke to perform actions in the room.
For example, using a URL parameter you can hide the bottom toolbar and create your own buttons for taking actions in the room:
Last updated