npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

agora-rtc-react

v2.1.0

Published

Agora RTC React SDK

Downloads

36,579

Readme

agora-rtc-react

Build Status

npm-version minified-size

Commitizen friendly Conventional Commits code style: prettier

English | 简体中文

agora-rtc-react makes it easier to integrate agora-rtc-sdk-ng in React applications.

Since 2.0.0, you no longer need to add agora-rtc-sdk-ng in your own package.json.

Installation

npm i agora-rtc-react

Usage

Here is the first one to get you started:

import AgoraRTC from "agora-rtc-sdk-ng";
import { AgoraRTCProvider } from "agora-rtc-react";

const Client = ({ children }) => {
  return (
    <AgoraRTCProvider client={AgoraRTC.createClient({ mode: "rtc", codec: "vp8" })}>
      {children}
    </AgoraRTCProvider>
  );
};
const root = createRoot(document.getElementById("container"));
root.render(<Client />);

This example will render Agora Client into a container on the page.

Examples

You can view examples on the website.

Or run in local by following steps:

  • add a .env.local file to each example directory and fill in the Agora account info following the format of .env.example.
  • pnpm start to start the example.

Components

  • RemoteVideoTrack — This component plays the video track of a remote user and does not support specifying the playback device.

  • RemoteUser — This component plays the video and audio tracks of a remote user and supports specifying the audio device to use. Specifying the video playback device is not supported.

  • RemoteAudioTrack — This component plays the audio track of a remote user with the playback device you specify.

  • LocalVideoTrack — This component plays the local video track using the playback device selected by the user in the browser.

  • LocalUser — This component plays the camera video track and the microphone audio track of the local user using the playback devices selected by the user in the browser.

  • LocalAudioTrack — This component plays the local audio track using the playback device selected by the user in the browser.

  • AgoraRTCScreenShareProvider — This component is a context provider, which lets all of the components inside children read the client prop you pass for screen sharing.

  • AgoraRTCProvider — This component is a context provider, which lets all of the components inside children read the client prop you pass.

Hooks

  • useVolumeLevel — Returns the volume level of an audio track at a frequency of once per second.

  • useTrackEvent — This hook lets you listen to specific events of the local or remote track.

  • useRemoteVideoTracks — This hook lets you automatically subscribe to and retrieve remote users' video tracks.

  • useRemoteUsers — This hook lets you retrieve the list of remote users.

  • useRemoteUserTrack — This hook lets you retrieve the audio or video track of a remote user.

  • useRemoteAudioTracks — This hook lets you automatically subscribe to and retrieve remote users' audio tracks.

  • useRTCClient — Returns the IAgoraRTCClient object.

  • usePublish — This hook lets you publish the local tracks when the component is ready and unpublish them when the component is unmounted.

  • useNetworkQuality — Returns the network quality of the local user.

  • useLocalScreenTrack — This hook lets you create a local video track for screen-sharing.

  • useLocalMicrophoneTrack — This hook lets you create a local microphone audio track. You can call this method multiple times in different components to create multiple tracks. To access the same track in multiple components, pass the same track object to those components.

  • useLocalCameraTrack — This hook lets you create a local camera video track. You can call this method multiple times in different components to create multiple tracks. To access the same track in multiple components, pass the same track object to those components.

  • useJoin — This hook lets a user automatically join a channel when the component is ready and automatically leaves the channel when the component is unmounted.

  • useIsConnected — Returns whether the SDK is connected to Agora's server.

  • useCurrentUID — Returns the current user ID.

  • useConnectionState — Returns the detailed connection state of the SDK.

  • useClientEvent — This hook lets you listen to specific events of the IAgoraRTCClient object.

  • useAutoPlayVideoTrack — This hook lets you automatically play a local or remote video track.

  • useAutoPlayAudioTrack — This hook lets you automatically play a local or remote audio track.

License

MIT © Agora.io