Learn about our RFC process, Open RFC meetings & more.Join in the discussion! »

react-jutsu

2.1.5 • Public • Published

<Jutsu />

A jitsi meet component wrapper and custom hook moulded with react's chakra 💠

View live demo

NPM

Install

yarn add react-jutsu

Add the Jitsi Meet API js file to the html body

<body>
  <script src='https://meet.jit.si/external_api.js'></script> 
</body>

Two options

You can use the provided component for simple scenarios or the hook for access to the jitsi meet api

import { Jutsu } from 'react-jutsu' // Component
import { useJitsi } from 'react-jutsu' // Custom hook

Sample Usage (Hook)

import React, { useEffect } from 'react'
import { useJitsi } from 'react-jutsu'
 
const App = () => {
  const roomName = 'konoha'
  const parentNode = 'jitsi-container'
  const jitsi = useJitsi({ roomName, parentNode })
 
  useEffect(() => {
    if (jitsi) {
      jitsi.addEventListener('videoConferenceJoined', () => {
        jitsi.executeCommand('displayName', 'Naruto Uzumaki')
        jitsi.executeCommand('password', 'dattebayo')
        jitsi.executeCommand('subject', 'fan')
      })
    }
    return () => jitsi && jitsi.dispose()
  }, [jitsi])
 
  return <div id={parentNode} />
}

Sample Usage (Component)

import React, { useState } from 'react'
 
import { Jutsu } from 'react-jutsu'
 
const App = () => {
  const [room, setRoom] = useState('')
  const [name, setName] = useState('')
  const [call, setCall] = useState(false)
  const [password, setPassword] = useState('')
 
  const handleClick = event => {
    event.preventDefault()
    if (room && name) setCall(true)
  }
 
  return call ? (
    <Jutsu
      roomName={room}
      displayName={name}
      password={password}
      loadingComponent={<p>loading ...</p>} />
  ) : (
    <form>
      <input id='room' type='text' placeholder='Room' value={room} onChange={(e) => setRoom(e.target.value)} />
      <input id='name' type='text' placeholder='Name' value={name} onChange={(e) => setName(e.target.value)} />
      <input id='password' type='text' placeholder='Password (optional)' value={password} onChange={(e) => setPassword(e.target.value)} />
      <button onClick={handleClick} type='submit'>
        Start / Join
      </button>
    </form>
  )
}
 
export default App

Supported Configuration

Check the Jitsi Meet API docs for full configuration and how to use api commands when using the useJitsi hook

Room Name

The meeting room name

This prop is required to start a meeting

Display Name

The participant's displayed name

This prop is optional

Password

The meeting room password

This prop is optional

Subject

The meeting subject (what is displayed at the top)

This prop is optional

<Jutsu 
  roomName='naruto'
  password='dattebayo'
  displayName='uzumaki'
  subject='fan'
/>

Domain

<Jutsu domain='my-custom-domain.com'>

Your Jitsi domain to use, the default value is meet.jit.si

Loading Component

<Jutsu loadingComponent={<ProgressBar />}>

An optional loading component, the default value is <p>Loading ...</p>

Styles

<div
  style={{...containerStyle, ...containerStyles}}
>
  <div
    style={{...jitsiContainerStyle, ...jitsiContainerStyles}}
  />
</div>

Internally Jutsu is constructed inside 2 containers, you can add custom styles for each by specifying containerStyles and jitsiContainerstyles

The default values are

const containerStyle = {
  width: '800px',
  height: '400px'
}
 
const jitsiContainerStyle = {
  display: loading ? 'none' : 'block', // <- used for loadingComponent logic
  width: '100%',
  height: '100%'
}

An example override could be

<Jutsu containerStyles={{ width: '1200px', height: '800px' }}>

License

MIT © this-fifo

Install

npm i react-jutsu

DownloadsWeekly Downloads

286

Version

2.1.5

License

MIT

Unpacked Size

27.4 kB

Total Files

8

Last publish

Collaborators

  • avatar