Quickstart
This quickstart shows how to use RealtimeKit's UI Kit prebuilt components to add live video and audio to your React application with minimal coding and a variety of meeting UI customization options.
For getting started quickly, you can use our sample code. You can clone and run a sample application from the React UI Kit GitHub repository.
Before Getting Started
-
Make sure you've read the Getting Started with RealtimeKit guide and completed the following steps:
- Create a developer account
- Create a Meeting
- Add Participant to the meeting
Step 1: Install the SDK
Since the UI Kit is built on top of the Core SDK, you must install the
@cloudflare/realtimekit
SDK along with the @cloudflare/realtimekit-react-ui
.
@cloudflare/realtimekit-react
consists of hooks written on top of our core @cloudflare/realtimekit
package, which makes it easy to use web-core
in React applications.
You can install the package using npm or Yarn.
- npm
- Yarn
- pnpm
npm install @cloudflare/realtimekit-react @cloudflare/realtimekit-react-ui
yarn add @cloudflare/realtimekit-react @cloudflare/realtimekit-react-ui
pnpm add @cloudflare/realtimekit-react @cloudflare/realtimekit-react-ui
Version
@cloudflare/realtimekit-react-ui | |
@cloudflare/realtimekit-react |
Step 2: Initialise meeting
Here's a series of steps that you need to perform:
- Set up
RealtimeKitProvider
. You need it to import theRealtimeKitProvider
from the@cloudflare/realtimekit-react
. This provides a meeting object to child components. - Initialize the client. Use the
useRealtimeKitClient()
hook andinitMeeting
to initialize a client. - Call the
init()
method and pass theauthToken
:
authToken | After you've created the meeting, add each participant to the meeting using the Add Participant API. The API response contains the authToken. |
import { useEffect } from 'react';
import { useRealtimeKitClient, RealtimeKitProvider } from '@cloudflare/realtimekit-react';
import { RTKMeeting } from '@cloudflare/realtimekit-react-ui';
export default function App() {
const [meeting, initMeeting] = useRealtimeKitClient();
useEffect(() => {
initMeeting({
authToken: '<auth-token>',
defaults: {
audio: false,
video: false,
},
});
}, []);
return (
<RealtimeKitProvider value={meeting}>
/**
* Coming in Step 3
*/
</RealtimeKitProvider>
);
}
Step 3: Use RTKMeeting
component
In the following example, a meeting is created using the useRealtimeKitClient
component. useRealtimeKitMeeting
returns the meeting object you passed to
the RealtimeKitProvider
.
RTKMeeting
renders the entire meeting UI. It loads your preset and renders
the UI based on it. With this component, you don't have to handle all the
states, dialogs, and other smaller bits of managing the application.
For more information on the other props of RTKMeeting
, see
RTKMeeting.
import { useEffect } from 'react';
import { useRealtimeKitClient, useRealtimeKitMeeting, RealtimeKitProvider } from '@cloudflare/realtimekit-react';
import { RTKMeeting } from '@cloudflare/realtimekit-react-ui';
export default function App() {
const [meeting, initMeeting] = useRealtimeKitClient();
useEffect(() => {
initMeeting({
authToken: '<auth-token>',
defaults: {
audio: false,
video: false,
},
});
}, []);
return (
<RealtimeKitProvider value={meeting}>
<MyMeetingUI />
</RealtimeKitProvider>
);
}