Quickstart
This quickstart shows how to use Dyte'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 Dyte topic and completed the following steps:
- Create a Dyte Developer Account
- Create a Dyte 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
react-web-core package along with the ui-kit.
react-web-core consists of hooks written on top of web-core 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 @dytesdk/react-ui-kit @dytesdk/react-web-core
yarn add @dytesdk/react-ui-kit @dytesdk/react-web-core
pnpm add @dytesdk/react-ui-kit @dytesdk/react-web-core
If you get errors when importing the react-ui-kit and react-web-core
packages, try installing them separately.
Version
| @dytesdk/react-ui-kit | |
| @dytesdk/react-web-core |
Step 2: Initialise meeting
Here's a series of steps that you need to perform:
- Set up
DyteProvider. You need it to import theDyteProviderfrom thedytesdk/react-web-core. DyteProvider basically is a hook wrapper on dytesdk/web-core. This provides a meeting object to child components. - Initialize the Dyte client. Use the
useDyteClient()hook andinitMeetingto 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 { useDyteClient, DyteProvider } from '@dytesdk/react-web-core';
import { DyteMeeting } from '@dytesdk/react-ui-kit';
export default function App() {
const [meeting, initMeeting] = useDyteClient();
useEffect(() => {
initMeeting({
authToken: '<auth-token>',
defaults: {
audio: false,
video: false,
},
});
}, []);
return (
<DyteProvider value={meeting}>
/**
* Coming in Step 3
*/
</DyteProvider>
);
}
Step 3: Use DyteMeeting component
In the following example, a meeting is created using the useDyteMeeting
component. useDyteMeeting essentially returns the meeting object you passed to
the DyteProvider.
DyteMeeting 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 DyteMeeting, see
DyteMeeting.
import { useEffect } from 'react';
import { useDyteClient, useDyteMeeting, DyteProvider } from '@dytesdk/react-web-core';
import { DyteMeeting } from '@dytesdk/react-ui-kit';
export default function App() {
const [meeting, initMeeting] = useDyteClient();
useEffect(() => {
initMeeting({
authToken: '<auth-token>',
defaults: {
audio: false,
video: false,
},
});
}, []);
return (
<DyteProvider value={meeting}>
<MyMeetingUI />
</DyteProvider>
);
}
export default function MyMeetingUI() {
const { meeting } = useDyteMeeting();
return (
<DyteMeeting mode="fill" meeting={meeting} showSetupScreen={false} />
);
}