Code Monkey home page Code Monkey logo

daily-react's Introduction

Daily React

Daily React makes it easier to integrate @daily-co/daily-js in React applications.

Usage

To get started with Daily React, include DailyProvider in your app:

import { DailyProvider } from '@daily-co/daily-react';

function App({ roomUrl }) {
  return (
    <DailyProvider url={roomUrl}>
      {/* โ€ฆ */}
    </DailyProvider>
  )
}

Then in your application you can access Daily React:

import { useParticipant, useParticipantIds } from '@daily-co/daily-react';

function ParticipantRow({ id }) {
  const participant = useParticipant(id);

  return (
    <li style={{ display: 'flex', gap: 8 }}>
      <span>{participant?.user_name ?? 'Guest'}</span>
      <span>๐Ÿ“ท{participant?.tracks?.video?.state === 'playable' ? 'โœ…' : 'โŒ'}</span>
      <span>๐ŸŽ™๏ธ{participant?.tracks?.audio?.state === 'playable' ? 'โœ…' : 'โŒ'}</span>
    </li>
  )
}

function Participants() {
  const participantIds = useParticipantIds({
    filter: 'remote',
    sort: 'user_name'
  });

  return (
    <ul>
      {participantIds.map((id) => <ParticipantRow key={id} id={id} />)}
    </ul>
  )
}

Learn more about Daily React by reading our docs at https://docs.daily.co/reference/daily-react.

Installation

The daily-react package is published to npm. To install the latest stable version, run one of the following commands:

npm install @daily-co/daily-react @daily-co/daily-js recoil

# or with yarn

yarn add @daily-co/daily-react @daily-co/daily-js recoil

Notice that @daily-co/daily-react requires @daily-co/daily-js and recoil as peer dependencies.

@daily-co/daily-react manages its internal state using recoil. You can read more about recoil in their Motivation statement.

Tests

We've set up automatic tests using jest and Testing Library. You can run the tests using the following command:

npm test

# or with yarn

yarn test

Contributions

Please head over to our contributing guide to learn more about how you can contribute to daily-react.

In case you've got general questions about Daily or need technical assistance, please reach out via [email protected].

daily-react's People

Contributors

regaddi avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.