2.0.11 • Published 2 years ago

@ivicos/react-jitsi v2.0.11

Weekly downloads
-
License
MIT
Repository
github
Last release
2 years ago

Jitsi Meet React Component

license built with typescript

Notes

The repository has been forked from https://github.com/gatteo/react-jitsi and adapted to the need for a custom Jitsi Meet implementation. The additional configuration and changes made regarding Ivicos custom Jitsi Meet implementation can be found in USAGE.md. The original documentation from the forked repository is accessible below.

An unofficial React component which wraps the standard Jitsi Meet JS API. It is written in Typescript to help you configure the library with ease, and get your super important meetings up and going, in a blink of an eye🌪.

Live Demo

Install

npm install react-jitsi --save

Usage

Basic

The easiest way for you to create a meeting is by simply including the React Jitsi component in your app.

import React, { useState } from 'react'
import Jitsi from 'react-jitsi'

export const App = () => (
  <>
    <h2>My First Meeting!</h2>
    <Jitsi />
  </>
)

However, this is not recommended, as it will create and join a random room (ex. hp6y791054a), which is possibly not unique.

Basic, but better

We advise you to create a meeting specifying at least a room name (that you know is unique) and the user's display name.

import React, { useState } from 'react'
import Jitsi from 'react-jitsi'

const roomName = 'my-super-secret-meeting-123e4567-e89b-12d3-a456-426655440000'
const userFullName = 'Joseph Strawberry'

export const App = () => (
  <>
    <h2>My First Meeting!</h2>
    <Jitsi roomName={roomName} displayName={userFullName} />
  </>
)

A more complete example

import React, { useState } from 'react'
import Jitsi from 'react-jitsi'
import Loader from './components/Loader'

export const App = () => {

  const [displayName, setDisplayName] = useState('')
  const [roomName, setRoomName] = useState('')
  const [password, setPassword] = useState('')
  const [onCall, setOnCall] = useState(false)

  return onCall
    ? (
      <Jitsi
        roomName={roomName}
        displayName={displayName}
        password={password}
        loadingComponent={Loader}
        onAPILoad={JitsiMeetAPI => console.log('Good Morning everyone!')}
      />)
    : (
      <>
        <h1>Create a Meeting</h1>
        <input type='text' placeholder='Room name' value={roomName} onChange={e => setRoomName(e.target.value)} />
        <input type='text' placeholder='Your name' value={displayName} onChange={e => setDisplayName(e.target.value)} />
        <button onClick={() => setOnCall(true)}> Let&apos;s start!</button>
      </>
    )

}

Custom styles

The Jitsi Meet conference iframe is wrapped by two containers

<div id='react-jitsi-container' style={...}>
  <Loader/>
  <div id='react-jitsi-frame' style={...}>
    <iframe>
  </div>
</div>

You can specify custom styles for each container in two ways:

  • Using CSS, through the #react-jitsi-container and #react-jitsi-frame selectors
  • Using inline styling, through the containerStyle and frameStyle props

For example

<Jitsi containerStyle={{ width: '1200px', height: '800px' }}>

Conference Configuration

Configuration over both the conference core settings (such as startAudioOnly option) and the interface settings (such as filmStripOnly option) can be passed through the config and interfaceConfig props.

For example

<Jitsi
  config={{ startAudioOnly: true }}
  interfaceConfig={{ filmStripOnly: true }}>

Available props

PropRequiredDescriptionDefault
containerStylenoObject containing main container styles (see above for details){ width:'800px', height: '400px' }
frameStylenoObject containing frame container styles (see above for details){ display: loading?'none' : 'block',width: '100%',height: '100% }'
loadingComponentnoComponent shown until the Jitsi Meet video conference is not started<div>Loading meeting...</div>
onAPILoadnoCallback function invoked with Jitsi Meet API object when the library is loaded
onIframeLoadnoCallback function invoked when the conference iframe is loaded
domainnoDomain used to build the conference URLmeet.jit.si
roomNamenoName of the room to joinA random string
passwordnoPassword to set for the meeting room
displayNamenoParticipant's name
confignoOverrides for the default meeting settings
interfaceConfignoOverrides for default meeting interface options
noSSLnoBoolean indicating if the server should be contacted using HTTP or HTTPStrue
jwtnoJWT token to pass to the domain
devicesnoA map containing information about the initial devices that will be used in the call.
userInfonoObject containing information about the participant opening the meeting

Controlling the Conference

The Jitsi Meet API exposes several methods which allow great control over the conference. Such methods can be accessed through the api object passed as an argument to the callback specified in the onAPILoad prop.

For example, to retrieve the device list:

import React, { useState } from 'react'
import Jitsi from 'react-jitsi'

const handleAPI = (JitsiMeetAPI) => {
  JitsiMeetAPI.executeCommand('toggleVideo')
}

export const App = () => (
  <>
    <h2>My First Meeting!</h2>
    <Jitsi onAPILoad={handleAPI} password={password} />
  </>
)

Contributing

We love contributions from everyone. If you have any bug to report, open an issue. If want to submit a fix, or any kind of improvement, create a pull request here on Github.

Organizations and projects using this component

Dascuola.itWestudents.it

If you are using this component in your organization/project and would like to be shown in the above list, send us an email!


MIT License.