MinChat Documentation
SupportHome
  • Introduction
  • Getting Started
    • Using Vanilla Javascript
    • Using React
    • Using React Native
  • Webhooks
    • Overview
  • Rest APIs
    • Overview
  • Websockets
    • Overview
  • Customize UI
    • Customizing React UI
  • Reference
    • User
    • Message
    • File
  • Javascript SDK
    • Overview
    • Conversation (Chat)
  • React SDK
    • Overview
    • useChats hook
    • useMessages hook
    • useUser hook
    • useMinChat
    • Conversation (Chat)
  • React Native SDK
    • Overview
    • useChats hook
    • useMessages hook
    • useUser hook
    • useMinChat
    • Conversation (Chat)
    • File
Powered by GitBook
On this page
  • Get Connected User
  • Create User
  • Fetching a user
  • Updating a user

Was this helpful?

  1. React Native SDK

useMinChat

Last updated 1 year ago

Was this helpful?

the useMinChat hook is used to access the minchat object

import { useMinChat } from '@minchat/reactnative'
 const minchat = useMinChat()

Get Connected User

get the user that is connected to the minchat instance. Returns a object.

 const user = minchat?.getConnectedUser()

Create User

You should create users in your MinChat application to initiate conversations with. Users are at the core of all conversations. MinChat applications are made up of users who chat in either group chats or one-to-one conversations.

in MinChat, a is a person that uses your app. Typically, you will have one MinChat for each user in your own database.

Usually, you would create users based on the data from your database. A is represented by a JSON object.

const otherUser = await minchat?.createUser({ 
                                  username: "example-username", 
                                  name: "Example Name",
                                  avatar: "urltoavatar.com/avatar.jpg" //optional
                            })
                            

You can view more details about the user parameters .

note: createUser(...) automatically creates a new user in the system, if a user with the same username already exists then it will reuse that user.

Fetching a user

You can fetch an already existing user using either their username or their id.


const otherUser = await minchat?.fetchUser("example-username")

const otherUser = await minchat?.fetchUserById("example-id")

Updating a user

You can update an existing user's information


const updatedUser = await minchat?.updateUserById("example-user-id",
                              { 
                                  name: "Updated Name",
                                  avatar: "urltoavatar.com/updated-avatar.jpg" 
                              })
                            

You can view more details about the user parameters .

User
User
User
User
here
here