A jitsi meet component wrapper and custom hook moulded with react's chakra ðŸ’
yarn add react-jutsu
<body>
<script src='https://meet.jit.si/external_api.js'></script>
</body>
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
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} />
}
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}
onMeetingEnd={() => console.log('Meeting has ended')}
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
Check the Jitsi Meet API docs for full configuration and how to use api commands when using the
useJitsi
hook
The meeting room name
This prop is required to start a meeting
The participant's displayed name
This prop is optional
The meeting room password
This prop is optional
Callback function executed after readyToClose event is fired
This prop is optional
The meeting subject (what is displayed at the top)
This prop is optional
<Jutsu
subject='fan'
roomName='naruto'
password='dattebayo'
displayName='uzumaki'
onMeetingEnd={() => console.log('Meeting has ended')}
/>
<Jutsu domain='my-custom-domain.com'>
Your Jitsi domain to use, the default value is meet.jit.si
<Jutsu loadingComponent={<ProgressBar />}>
An optional loading component, the default value is <p>Loading ...</p>
<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' }}>
MIT © this-fifo