This package has been deprecated

Author message:

DEPRECATED: This package has been deprecated use @livekit/components-react instead

@livekit/react-core
TypeScript icon, indicating that this package has built-in type declarations

1.1.0 • Public • Published

Livekit React Core

Install

npm install --save @livekit/react-core livekit-client

Using hooks

The provided components make use of two hooks: useRoom and useParticipant, they will help you manage internal LiveKit callbacks and map them into state variables that are ready-to-use from React components.

Using the connect function returned by useRoom will ensure that callbacks are registered automatically and the other state variables are updated when changes take place in the room.

import { useRoom, useParticipant } from '@livekit/react-core'

export const MyComponent = () => {
  const roomOptions: RoomOptions = {
    adaptiveStream: true,
    dynacast: true,
  }
  const { connect, isConnecting, room, error, participants, audioTracks } = useRoom(roomOptions);

  async function init() {
    // initiate connection to the livekit room
    await connect(livekitUrl, livekitToken);
    // request camera and microphone permissions and publish tracks
    await room.localParticipant.enableCameraAndMicrophone();
    ...
  }

  useEffect(() => {
    init().catch(console.error)
  }, [])

  return (...)
}

export const ParticipantRenderer = ({ participant }) => {
  const { isSpeaking, subscribedTracks } = useParticipant(participant)
  ...
}

Rendering video and audio

When building your custom UI, it's helpful to use track renderers that are provided in this library. AudioRenderer and VideoRenderer would render an audio and video track, respectively.

Readme

Keywords

none

Package Sidebar

Install

npm i @livekit/react-core

Weekly Downloads

1,016

Version

1.1.0

License

Apache-2.0

Unpacked Size

132 kB

Total Files

18

Last publish

Collaborators

  • rdsa
  • thedavidzhao
  • feepslk
  • matkam_livekit
  • raja-livekit
  • livekitherzog
  • lukasio
  • paulwe
  • dliulk
  • lk_hiroshi
  • dc-livekit
  • cnderrauber
  • benjaminlivekit
  • danm_livekit
  • shishir.gowda
  • duanweiwei
  • ocupe_livekit
  • cacheonly
  • sfkat
  • shayps
  • chrisackermann
  • bcherrylk
  • kuba--
  • enbyspace
  • rektdeckard
  • lk-mike
  • braunsteinlivekit
  • s-hamdananwar
  • anunay_lk