How the architecture of use-chat works
mainThe library is a headless state management tool for chat applications, composed of three main parts:
- Storage: The source of truth where state (conversations, messages, users, etc.) is kept. You can use the provided
BasicStorageor implement your ownIStorage(e.g., using Redux). - ChatProvider: A React context provider that connects the storage and the service factory to your application.
- useChat: The primary hook used in your components to access chat state and methods.
To connect to a real backend, you must implement the IChatService interface. This service handles the communication protocol (sending/receiving messages, typing indicators, etc.).