Skip to main content

Quickstart

Before Getting Started

Before you start integrating RealtimeKit into your application, make sure you've read the Getting Started with RealtimeKit topic and completed the steps in the Integrate RealtimeKit section.

The RealtimeKitClient is the root class of the SDK. It is the main entry point of the SDK. It is the only class that you need to instantiate in order to use the SDK.

To instantiate RealtimeKitClient, you can run the following command:

import React from 'react';
import { useRealtimeKitClient, RealtimeKitProvider } from '@cloudflare/realtimekit-react-native';

export default function App() {
const [meeting, initMeeting] = useRealtimeKitClient();
React.useEffect(() => {
const init = async () => {
const meetingOptions = {
audio: true,
video: true,
};
await initMeeting({
authToken: 'YourAuthToken',
defaults: meetingOptions,
});
};
init();
if (meeting) meeting.joinRoom();
}, []);

if (meeting)
return (
<RealtimeKitProvider value={meeting}>
{/* Render you Components here*/}
{/* Components rendered inside RealtimeKitProvider can access RealtimeKitClient object using useRealtimeKitClient() hook */}
</RealtimeKitProvider>
);
}

You can get the authToken using our backend APIs and then pass it to the init method of RealtimeKitClient.

info

Once join room process completes roomJoined event is emitted on meeting.self namespace. If you want to take any actions like enabling audio, video or start and stop recording etc. it should be done after the roomJoined event is fired.

For example:

meeting.self.on('roomJoined', () => {
console.log('User has joined the room', meeting.self.roomJoined);
// run my actions.
});

await meeting.joinRoom();

Leave room

Leave the meeting room.

await meeting.leaveRoom();