iFrame
React iFrame

React iFrame

Our iFrame package allows you to embed ready to use Huddle01 app in your React application. You can customize the appearance using the configuration options provided by the package.

Prerequisites

Ensure that you have the most recent version of Node.js installed on your device. The latest version of Node.js can be downloaded from here (opens in a new tab).

Installation

To install the @huddle01/iframe package, use either npm, pnpm or yarn.

pnpm add @huddle01/iframe

Usage

⚠️

@huddle01/huddle01-iframe has been deprecated, use @huddle01/iframe instead.

💡

You need to generate roomId using our Create Room API and projectId from Developer Dashboard (opens in a new tab)

Import the HuddleIframe component from the @huddle01/iframe package.

import { HuddleIframe } from "@huddle01/iframe";
 
function App() {
  return (
    <div>
      <HuddleIframe
        roomUrl='https://iframe.huddle01.com/YOUR_ROOM_ID'
        className='w-full aspect-video'
        projectId={"YOUR_PROJECT_ID"}
      />
    </div>
  );
}

Methods

You can also use the instance methods to interact with the iFrame. To use the methods listed below, you first need to get the iFrame element and its content window. It's better to call these methods after app:initialized event is triggered.

⚠️

@huddle01/huddle01-iframe has been deprecated, use @huddle01/iframe instead.

import { HuddleIframe, iframeApi, useEventListener } from "@huddle01/iframe";
 
useEventListener("app:initialized", () => {
  iframeApi.initialize({
    background: "YOUR_BACKGROUND_URL",
    logoUrl: "YOUR_LOGO_URL",
  });
 
  iframeApi.changeAvatarUrl("YOUR_AVATAR_URL");
});

Available Methods

Initialize

Pass a config to customize meeting room appearance. You need to pass following options to the iframeApi.initialize() method.

💡

Don't use the useEffect hook to call iframeApi.initialize() for the first time, use the useEventListener hook instead

MethodDescriptionParameter
logoUrlChange the default logo in the meeting roomstring
backgroundChange the background of the meeting roomstring
redirectUrlOnLeaveRedirect to a given URL after the meeting endsstring
virtualBgsLinks to additional virtual backgrounds for the meeting.string[]

Example Usage

iframeApi.initialize({
  background: "YOUR_BACKGROUND_URL",
  logoUrl: "YOUR_LOGO_URL",
  redirectUrlOnLeave: "YOUR_REDIRECT_URL",
  virtualBgs: ["BG_URL_1", "BG_URL_2"],
});

Enable/Disable Features

You can enable or disable the following features by calling iframeApi.updateFeatures() method.

MethodDescriptionParameterDefault
isChatEnabledEnable chat featurebooleantrue
isReactionsEnabledEnable reactions featurebooleantrue
isVirtualBgEnabledEnable virtual background featurebooleantrue
isCopyInviteLinkEnabledEnable copy invite link featurebooleanfalse
isRecordingEnabledEnable recording functionalitybooleantrue
isScreenShareEnabledEnable screen share featurebooleantrue
isRoomLockedEnable lock screen optionbooleantrue

Example Usage

iframeApi.updateFeatures({
  isChatEnabled: true,
  isReactionsEnabled: true,
  isVirtualBgEnabled: true,
  isCopyInviteLinkEnabled: true,
  isRecordingEnabled: true,
  isScreenShareEnabled: true,
  isRoomLocked: true,
});

Other Methods

You can also handle media devices, send reactions and other actions using the following methods:

MethodDescriptionParameter
muteMicMute the user's microphonevoid
unmuteMicUnmute the user's microphonevoid
enableShareEnable screen sharingvoid
disableShareDisable screen sharingvoid
startRecordingStart recording the meetingvoid
stopRecordingStop recording the meetingvoid
sendReactionSend a reaction during the meetingstring
changeAvatarUrlChange the avatarUrl for your peer once joined roomstring

Example Usage

iframeApi.muteMic();
iframeApi.unmuteMic();
iframeApi.enableShare();
iframeApi.disableShare();
iframeApi.startRecording();
iframeApi.stopRecording();
iframeApi.sendReaction("😂");
iframeApi.changeAvatarUrl("YOUR_AVATAR_URL");

Events

You can listen to the following events using the useEventListener hook:

EventDescriptionData
app:initializedTriggered when the app is initialized
lobby:metadataTriggered when the lobby metadata is updatedTPreviewPeers
room:joinedTriggered when a user joins the room
room:failedTriggered when a user fails to join the roomreason: TRejectReasons
room:new-peerTriggered when a new peer joins the roomTPeerData
room:me-leftTriggered when the user leaves the room
room:peer-leftTriggered when a peer leaves the roompeerId: string
room:recording-startedTriggered when the recording starts
room:recording-stoppedTriggered when the recording stopsTRecData
room:livestream-startedTriggered when the livestream starts
room:livestream-stoppedTriggered when the livestream stops

Example Usage

import { useEventListener } from "@huddle01/iframe";
 
useEventListener("lobby:metadata", (data) => console.log({ data }));
useEventListener("room:joined", () => console.log("User joined the room"));
useEventListener("room:failed", (reason) => console.log({ reason }));
Audio/Video Infrastructure designed for developers to empower them to ship simple yet powerful Audio/Video Apps.
support
company
Copyright © 2024 Graphene 01, Inc. All Rights Reserved.