This tutorial teaches you to integrate Sendbird UIKit for React in your web application.
A list of channels and chat view using Sendbird UIKit for React.
Before you start, you need the following:
Next, create a user in your Sendbird application:
The easiest way to create a new React project is by using Vite. You can use either npm
or yarn
to create a new project.
npm create vite uikit-react-example -- --template react-ts
cd uikit-react-example
npm install
yarn create vite uikit-react-example --template react-ts
cd uikit-react-example
yarn
You can install UIKit for React through npm or yarn.
npm i @sendbird/uikit-react
yarn add @sendbird/uikit-react
You can now implement the chat interface to your web app using the App
component from Sendbird UIKit. Replace the content in your App.tsx
file with the following code:
import { App as SendbirdApp } from '@sendbird/uikit-react';
import '@sendbird/uikit-react/dist/index.css';
function App() {
return (
<div style={{ width:'100vw', height:'100vh' }}>
{/*
This super smart component serves as a drop-in chat solution
For advanced 🚀 customizations, use SendbirdProvider:
https://sendbird.com/docs/chat/uikit/v3/react/essentials/sendbirdprovider
*/}
<SendbirdApp
appId={'YOUR_APP_ID'}
userId={'USER_ID'}
accessToken={'ACCESS_TOKEN'} // Optional, but recommended
/>
</div>
)
}
export default App;
Replace these values:
YOUR_APP_ID
: Your Sendbird Application IDUSER_ID
: The user ID you created earlierNote: You can find the user's Access token in the Sendbird Dashboard under your Application > Users > your user > Access token. For this tutorial, you are using the user access token as a way of authentication. For actual implementation, itt is highly recommended to refer to this authentication guide to implement a more secure way of authentication.
Now let's test the chat interface by sending a message.
npm run dev
oryarn dev
🎉 You've successfully: