useCreateChatClient

A hook that creates a new Chat client and automatically connects/disconnects a user.

Usage

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>;
};

Parameters

NameTypeRequiredDescription
apiKeystringYesThe API key for the Stream Chat API.
userDataOwnUserResponse | UserResponseYesThe user data for the user to connect.
tokenOrProviderTokenOrProviderYesThe token or provider for the user to connect.
optionsStreamChatOptionsNoThe options for the Chat client.

Returns

A Chat client instance.