Solid component and library for LiveKit (unofficial)

Overview

LiveKit Solid Component Library

This package provides Solid components that makes it easier to use LiveKit in a Solid app.

Inspired completely by https://github.com/livekit/livekit-react

NPM npm bundle size (scoped) npm bundle size (scoped version) Libraries.io dependency status for latest release, scoped npm package NPM

Table of Contents

Installation

This library is available through the npm registry.

NPM

$ npm -i solid-livekit

Yarn

$ yarn add solid-livekit

Demo

https://solid-livekit.netlify.app/

Source available in example

Usage

Video room with built-in UI

Without customization, the component would use a default skin as seen in the demo above.

import { LiveKitRoom } from 'solid-livekit'
// CSS should be explicitly imported if you want to use the default UI
import 'solid-livekit/dist/esm/index.css'

export const RoomPage = () => {
  const url = 'wss://your_host'
  const token = 'your_token'
  return (
    <div className="roomContainer">
      <LiveKitRoom 
        url={url}
        token={token}
        onConnected={room => onConnected(room)}
      />
    </div>
  )
}

async function onConnected(room) {
  await room.localParticipant.setCameraEnabled(true)
  await room.localParticipant.setMicrophoneEnabled(true)
}

Customize rendering

To provide your own rendering, override one or more of stageRenderer, participantRenderer, and controlRenderer. It's possible customize a single renderer and use defaults for the others.

export const RoomPage = () => {
  const url = 'wss://your_host'
  const token = 'your_token'
  return (
    <LiveKitRoom url={url} token={token}
      // stageRenderer renders the entire stage
      stageRenderer={(props: StageProps) => { return <div/> }}
      // participantRenderer renders a single participant
      participantRenderer={(props: ParticipantProps) => { return <div/> }}
      // controlRenderer renders the control bar
      controlRenderer={(props: ControlsProps) => { return <div/> }}
    />
  )
}

Using custom hooks

The provided components make use of two hooks: createRoom and createParticipant, 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 createRoom will ensure that callbacks are registered automatically and the other state variables are updated when changes take place in the room.

import { createRoom, createParticipant } from 'solid-livekit'

export const MyComponent = () => {
  const room = createRoom();
  // room().connect
  // room().isConnecting
  // room().room
  // room().error
  // room().participants
  // room().audioTracks
  ...
}

export const ParticipantRenderer = ({ participant }) => {
  const participant = createParticipant(participant);
  // participant().isSpeaking
  // participant().subscribedTracks
  // ...
  ...
}

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.

Authors

See also the list of contributors who participated in this project.

Changelog

Changelog

License

MIT

You might also like...

A unofficial Node.js library for HoYoWiki API, can get the details of Genshin Impact items!

HoYoWiki API (Node.js Library) English | 繁體中文 | 简体中文 A unofficial Node.js library for HoYoWiki API, can get the details of Genshin Impact items! Repor

Jul 17, 2022

Solid.js library adding a services layer for global shared state.

Solid.js library adding a services layer for global shared state.

Solid Services Services are "global" objects useful for features that require shared state or persistent connections. Example uses of services might i

Dec 30, 2022

A ~2kb hotkeys library for solid that adds only 2 event listeners.

A ~2kb hotkeys library for solid that adds only 2 event listeners.

Solid Hotkeys - Cmd+S+H Solid Hotkeys is the easiest way to add hotkeys to your application. Built for and with Solid. Motivation You gotta have hotke

Aug 1, 2022

Unofficial API client for the Tidbyt API. Use this client to control Tidbyt devices and integrate with other services.

Tidbyt Client for Node.js Unofficial API client for the Tidbyt API. Use this client to control Tidbyt devices and integrate with other services. Insta

Dec 17, 2022

A simple (and unofficial) GitHub Trending client that lives in your menubar.

A simple (and unofficial) GitHub Trending client that lives in your menubar.

Raise A simple (and unofficial) GitHub Trending client that lives in your menubar. 📸 Screenshots 🖥 Installation New!! Raise is now available as a Ch

Dec 20, 2022

An unofficial companion tool created for use alongside PhotoPrism to enable API endpoints and automation.

PhotoPrism Helper PhotoPrism Helper is an unofficial companion tool created for use alongside PhotoPrism. This project isn't associated with the Photo

Dec 25, 2022

This is an unofficial front end for Hacker News, reminiscent of the Windows XP era Outlook email client on a Windows XP default desktop

This is an unofficial front end for Hacker News, reminiscent of the Windows XP era Outlook email client on a Windows XP default desktop

Hacker XP Hacker News styled as the Windows XP Outlook email client. Try out Hacker XP here! Description This is an unofficial front end for Hacker Ne

Jul 12, 2022

Unofficial HelmRelease search through awesome k8s-at-home projects

Unofficial HelmRelease search through awesome k8s-at-home projects

k8s at home search (unofficial) Search Flux HelmReleases through awesome k8s-at-home projects, check it out at https://whazor.github.io/k8s-at-home-se

Jan 2, 2023

Unofficial WhatsApp Linux client built with Electron.

WhatsApp Desktop for Linux (unofficial) WhatsApp Linux client built with Electron. As WhatsApp doesn't compile the official app for Linux, here is an

Jan 3, 2023
Owner
Prince Neil Cedrick Castro
Loves to learn, build, and help. Software Engineer and Architect @LyonInc.
Prince Neil Cedrick Castro
Grupprojekt för kurserna 'Javascript med Ramverk' och 'Agil Utveckling'

JavaScript-med-Ramverk-Laboration-3 Grupprojektet för kurserna Javascript med Ramverk och Agil Utveckling. Utvecklingsguide För information om hur utv

Svante Jonsson IT-Högskolan 3 May 18, 2022
Hemsida för personer i Sverige som kan och vill erbjuda boende till människor på flykt

Getting Started with Create React App This project was bootstrapped with Create React App. Available Scripts In the project directory, you can run: np

null 4 May 3, 2022
Kurs-repo för kursen Webbserver och Databaser

Webbserver och databaser This repository is meant for CME students to access exercises and codealongs that happen throughout the course. I hope you wi

null 14 Jan 3, 2023
hCaptcha Component Library for Solid.

Solid hCaptcha Component Library This is a port of @hcaptcha/react-hcaptcha for Solid. Description hCaptcha is a drop-replacement for reCAPTCHA that p

Mikkel RINGAUD 5 Dec 4, 2022
UI component library for Solid.js with SSR support

Dolmen Dolmen is a themeable UI component library designed to work with Solid.js and optimized for SSR (Server-side rendering). It provides a broad se

Talin 14 Dec 17, 2022
🔥 Set up your new Solid component library in seconds!

Create Solid Library Create SolidJS libraries with ease! Usage npx create-solid-library <name> Development Developing components is often a visual pro

blusk 6 Oct 28, 2022
Simple and minimal split pane component for Solid!

solid-split-pane Split pane component for Solid! Uses Split.Js under the hood. Takes all props that split.js takes, plus a gutterClass. (Q) Why not so

blusk 5 Oct 28, 2022
👇 Bread n butter utility for component-tied mouse/touch gestures in Solid.

solid-gesture solid-gesture is a port of @use-gesture/react which lets you bind richer mouse and touch events to any component or view. With the data

Robert Soriano 8 Sep 30, 2022
An unofficial, simplified version of the @Shopify/koa-shopify-auth middleware library.

simple-koa-shopify-auth https://www.npmjs.com/package/simple-koa-shopify-auth NOTE: This package is not maintained by or affiliated with Shopify. Desc

David 20 Nov 7, 2022
Unofficial Library for using Discord.JS with JSX Syntax.

@chooks22/discord.jsx WARNING! This project is in very early stage of development. And while I do have plans to finish it to completion, consider this

Chooks22 4 Nov 14, 2022