Skip to content

A wrapper for Agora RTM Web SDK to use with react/reactjs

Notifications You must be signed in to change notification settings

GeekMikle/Agora-RTM-React

 
 

Repository files navigation

Agora RTM SDK React Wrapper

A thin react.js wrapper for Agora RTM SDK.

This wrapper supports React >= v16.8

Install

npm install agora-rtm-react

Usage

import React from 'react'
import { createChannel, createClient, RtmMessage } from 'agora-rtm-react'

const useClient = createClient('<Agora App ID>');
const useChannel = createChannel('channelName')

const App = () => {
  const client = useClient();
  const testChannel = useChannel(client)

  const login = async () => {
    await client.login({ uid: 'userId' })
    await testChannel.join()
  }
  
  const sendMsg = async (text: string) => {
    const message = client.createMessage({ text, messageType: 'TEXT' })
    await testChannel.sendMessage(message)
  }
...
}

Example

A chat example using the wrapper can be found in ./example

Docs

You can view the wrapper docs, Web SDK docs and the SDK API Reference

About

A wrapper for Agora RTM Web SDK to use with react/reactjs

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • TypeScript 80.3%
  • HTML 16.0%
  • CSS 3.7%