import { useCreateChatClient } from "stream-chat-react-native";
const App = () => {
const chatClient = useCreateChatClient({
apiKey: "YOUR_API_KEY",
userData: {
id: "YOUR_USER_ID",
name: "YOUR_USER_NAME",
},
tokenOrProvider: "YOUR_TOKEN_OR_PROVIDER",
});
return <Chat client={chatClient}>{/** Your app components */}</Chat>;
};useCreateChatClient
A hook that creates a new Chat client and automatically connects/disconnects a user.
Usage
Parameters
| Name | Type | Required | Description |
|---|---|---|---|
| apiKey | string | Yes | The API key for the Stream Chat API. |
| userData | OwnUserResponse | UserResponse | Yes | The user data for the user to connect. |
| tokenOrProvider | TokenOrProvider | Yes | The token or provider for the user to connect. |
| options | StreamChatOptions | No | The options for the Chat client. |
Returns
A Chat client instance.