@kesha-antonov/react-native-chat 4.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (263) hide show
  1. package/LICENSE +22 -0
  2. package/README.md +1087 -0
  3. package/lib/Actions.d.ts +16 -0
  4. package/lib/Actions.d.ts.map +1 -0
  5. package/lib/Actions.js +64 -0
  6. package/lib/Actions.js.map +1 -0
  7. package/lib/Avatar.d.ts +19 -0
  8. package/lib/Avatar.d.ts.map +1 -0
  9. package/lib/Avatar.js +93 -0
  10. package/lib/Avatar.js.map +1 -0
  11. package/lib/Bubble/index.d.ts +6 -0
  12. package/lib/Bubble/index.d.ts.map +1 -0
  13. package/lib/Bubble/index.js +391 -0
  14. package/lib/Bubble/index.js.map +1 -0
  15. package/lib/Bubble/styles.d.ts +57 -0
  16. package/lib/Bubble/styles.d.ts.map +1 -0
  17. package/lib/Bubble/styles.js +59 -0
  18. package/lib/Bubble/styles.js.map +1 -0
  19. package/lib/Bubble/types.d.ts +62 -0
  20. package/lib/Bubble/types.d.ts.map +1 -0
  21. package/lib/Bubble/types.js +2 -0
  22. package/lib/Bubble/types.js.map +1 -0
  23. package/lib/Chat/index.d.ts +10 -0
  24. package/lib/Chat/index.d.ts.map +1 -0
  25. package/lib/Chat/index.js +243 -0
  26. package/lib/Chat/index.js.map +1 -0
  27. package/lib/Chat/styles.d.ts +13 -0
  28. package/lib/Chat/styles.d.ts.map +1 -0
  29. package/lib/Chat/styles.js +13 -0
  30. package/lib/Chat/styles.js.map +1 -0
  31. package/lib/Chat/types.d.ts +102 -0
  32. package/lib/Chat/types.d.ts.map +1 -0
  33. package/lib/Chat/types.js +2 -0
  34. package/lib/Chat/types.js.map +1 -0
  35. package/lib/ChatAvatar.d.ts +12 -0
  36. package/lib/ChatAvatar.d.ts.map +1 -0
  37. package/lib/ChatAvatar.js +100 -0
  38. package/lib/ChatAvatar.js.map +1 -0
  39. package/lib/ChatContext.d.ts +12 -0
  40. package/lib/ChatContext.d.ts.map +1 -0
  41. package/lib/ChatContext.js +10 -0
  42. package/lib/ChatContext.js.map +1 -0
  43. package/lib/Color.d.ts +18 -0
  44. package/lib/Color.d.ts.map +1 -0
  45. package/lib/Color.js +18 -0
  46. package/lib/Color.js.map +1 -0
  47. package/lib/Composer.d.ts +9 -0
  48. package/lib/Composer.d.ts.map +1 -0
  49. package/lib/Composer.js +63 -0
  50. package/lib/Composer.js.map +1 -0
  51. package/lib/Constant.d.ts +8 -0
  52. package/lib/Constant.d.ts.map +1 -0
  53. package/lib/Constant.js +8 -0
  54. package/lib/Constant.js.map +1 -0
  55. package/lib/Day/index.d.ts +5 -0
  56. package/lib/Day/index.d.ts.map +1 -0
  57. package/lib/Day/index.js +39 -0
  58. package/lib/Day/index.js.map +1 -0
  59. package/lib/Day/styles.d.ts +21 -0
  60. package/lib/Day/styles.d.ts.map +1 -0
  61. package/lib/Day/styles.js +22 -0
  62. package/lib/Day/styles.js.map +1 -0
  63. package/lib/Day/types.d.ts +17 -0
  64. package/lib/Day/types.d.ts.map +1 -0
  65. package/lib/Day/types.js +2 -0
  66. package/lib/Day/types.js.map +1 -0
  67. package/lib/InputToolbar.d.ts +36 -0
  68. package/lib/InputToolbar.d.ts.map +1 -0
  69. package/lib/InputToolbar.js +108 -0
  70. package/lib/InputToolbar.js.map +1 -0
  71. package/lib/LoadEarlierMessages.d.ts +17 -0
  72. package/lib/LoadEarlierMessages.d.ts.map +1 -0
  73. package/lib/LoadEarlierMessages.js +44 -0
  74. package/lib/LoadEarlierMessages.js.map +1 -0
  75. package/lib/Message/index.d.ts +6 -0
  76. package/lib/Message/index.d.ts.map +1 -0
  77. package/lib/Message/index.js +180 -0
  78. package/lib/Message/index.js.map +1 -0
  79. package/lib/Message/styles.d.ts +18 -0
  80. package/lib/Message/styles.d.ts.map +1 -0
  81. package/lib/Message/styles.js +18 -0
  82. package/lib/Message/styles.js.map +1 -0
  83. package/lib/Message/types.d.ts +28 -0
  84. package/lib/Message/types.d.ts.map +1 -0
  85. package/lib/Message/types.js +2 -0
  86. package/lib/Message/types.js.map +1 -0
  87. package/lib/MessageAudio.d.ts +3 -0
  88. package/lib/MessageAudio.d.ts.map +1 -0
  89. package/lib/MessageAudio.js +24 -0
  90. package/lib/MessageAudio.js.map +1 -0
  91. package/lib/MessageImage.d.ts +12 -0
  92. package/lib/MessageImage.d.ts.map +1 -0
  93. package/lib/MessageImage.js +164 -0
  94. package/lib/MessageImage.js.map +1 -0
  95. package/lib/MessageReply.d.ts +15 -0
  96. package/lib/MessageReply.d.ts.map +1 -0
  97. package/lib/MessageReply.js +102 -0
  98. package/lib/MessageReply.js.map +1 -0
  99. package/lib/MessageText.d.ts +24 -0
  100. package/lib/MessageText.d.ts.map +1 -0
  101. package/lib/MessageText.js +51 -0
  102. package/lib/MessageText.js.map +1 -0
  103. package/lib/MessageVideo.d.ts +3 -0
  104. package/lib/MessageVideo.d.ts.map +1 -0
  105. package/lib/MessageVideo.js +24 -0
  106. package/lib/MessageVideo.js.map +1 -0
  107. package/lib/MessagesContainer/components/DayAnimated/debug.d.ts +8 -0
  108. package/lib/MessagesContainer/components/DayAnimated/debug.d.ts.map +1 -0
  109. package/lib/MessagesContainer/components/DayAnimated/debug.js +38 -0
  110. package/lib/MessagesContainer/components/DayAnimated/debug.js.map +1 -0
  111. package/lib/MessagesContainer/components/DayAnimated/index.d.ts +5 -0
  112. package/lib/MessagesContainer/components/DayAnimated/index.d.ts.map +1 -0
  113. package/lib/MessagesContainer/components/DayAnimated/index.js +123 -0
  114. package/lib/MessagesContainer/components/DayAnimated/index.js.map +1 -0
  115. package/lib/MessagesContainer/components/DayAnimated/styles.d.ts +12 -0
  116. package/lib/MessagesContainer/components/DayAnimated/styles.d.ts.map +1 -0
  117. package/lib/MessagesContainer/components/DayAnimated/styles.js +12 -0
  118. package/lib/MessagesContainer/components/DayAnimated/styles.js.map +1 -0
  119. package/lib/MessagesContainer/components/DayAnimated/types.d.ts +22 -0
  120. package/lib/MessagesContainer/components/DayAnimated/types.d.ts.map +1 -0
  121. package/lib/MessagesContainer/components/DayAnimated/types.js +2 -0
  122. package/lib/MessagesContainer/components/DayAnimated/types.js.map +1 -0
  123. package/lib/MessagesContainer/components/DayAnimated/useScrollGatedOpacity.d.ts +4 -0
  124. package/lib/MessagesContainer/components/DayAnimated/useScrollGatedOpacity.d.ts.map +1 -0
  125. package/lib/MessagesContainer/components/DayAnimated/useScrollGatedOpacity.js +37 -0
  126. package/lib/MessagesContainer/components/DayAnimated/useScrollGatedOpacity.js.map +1 -0
  127. package/lib/MessagesContainer/components/Item/index.d.ts +6 -0
  128. package/lib/MessagesContainer/components/Item/index.d.ts.map +1 -0
  129. package/lib/MessagesContainer/components/Item/index.js +86 -0
  130. package/lib/MessagesContainer/components/Item/index.js.map +1 -0
  131. package/lib/MessagesContainer/components/Item/types.d.ts +22 -0
  132. package/lib/MessagesContainer/components/Item/types.d.ts.map +1 -0
  133. package/lib/MessagesContainer/components/Item/types.js +2 -0
  134. package/lib/MessagesContainer/components/Item/types.js.map +1 -0
  135. package/lib/MessagesContainer/components/dayLayout.d.ts +10 -0
  136. package/lib/MessagesContainer/components/dayLayout.d.ts.map +1 -0
  137. package/lib/MessagesContainer/components/dayLayout.js +37 -0
  138. package/lib/MessagesContainer/components/dayLayout.js.map +1 -0
  139. package/lib/MessagesContainer/index.d.ts +6 -0
  140. package/lib/MessagesContainer/index.d.ts.map +1 -0
  141. package/lib/MessagesContainer/index.js +308 -0
  142. package/lib/MessagesContainer/index.js.map +1 -0
  143. package/lib/MessagesContainer/styles.d.ts +55 -0
  144. package/lib/MessagesContainer/styles.d.ts.map +1 -0
  145. package/lib/MessagesContainer/styles.js +42 -0
  146. package/lib/MessagesContainer/styles.js.map +1 -0
  147. package/lib/MessagesContainer/types.d.ts +91 -0
  148. package/lib/MessagesContainer/types.d.ts.map +1 -0
  149. package/lib/MessagesContainer/types.js +10 -0
  150. package/lib/MessagesContainer/types.js.map +1 -0
  151. package/lib/Models.d.ts +67 -0
  152. package/lib/Models.d.ts.map +1 -0
  153. package/lib/Models.js +2 -0
  154. package/lib/Models.js.map +1 -0
  155. package/lib/QuickReplies.d.ts +16 -0
  156. package/lib/QuickReplies.d.ts.map +1 -0
  157. package/lib/QuickReplies.js +107 -0
  158. package/lib/QuickReplies.js.map +1 -0
  159. package/lib/Reactions/MessageReactions.d.ts +5 -0
  160. package/lib/Reactions/MessageReactions.d.ts.map +1 -0
  161. package/lib/Reactions/MessageReactions.js +83 -0
  162. package/lib/Reactions/MessageReactions.js.map +1 -0
  163. package/lib/Reactions/ReactionPicker.d.ts +10 -0
  164. package/lib/Reactions/ReactionPicker.d.ts.map +1 -0
  165. package/lib/Reactions/ReactionPicker.js +84 -0
  166. package/lib/Reactions/ReactionPicker.js.map +1 -0
  167. package/lib/Reactions/index.d.ts +6 -0
  168. package/lib/Reactions/index.d.ts.map +1 -0
  169. package/lib/Reactions/index.js +6 -0
  170. package/lib/Reactions/index.js.map +1 -0
  171. package/lib/Reactions/types.d.ts +79 -0
  172. package/lib/Reactions/types.d.ts.map +1 -0
  173. package/lib/Reactions/types.js +2 -0
  174. package/lib/Reactions/types.js.map +1 -0
  175. package/lib/Reply/index.d.ts +2 -0
  176. package/lib/Reply/index.d.ts.map +1 -0
  177. package/lib/Reply/index.js +2 -0
  178. package/lib/Reply/index.js.map +1 -0
  179. package/lib/Reply/types.d.ts +72 -0
  180. package/lib/Reply/types.d.ts.map +1 -0
  181. package/lib/Reply/types.js +2 -0
  182. package/lib/Reply/types.js.map +1 -0
  183. package/lib/ReplyPreview.d.ts +14 -0
  184. package/lib/ReplyPreview.d.ts.map +1 -0
  185. package/lib/ReplyPreview.js +94 -0
  186. package/lib/ReplyPreview.js.map +1 -0
  187. package/lib/Send.d.ts +19 -0
  188. package/lib/Send.d.ts.map +1 -0
  189. package/lib/Send.js +56 -0
  190. package/lib/Send.js.map +1 -0
  191. package/lib/SystemMessage.d.ts +14 -0
  192. package/lib/SystemMessage.d.ts.map +1 -0
  193. package/lib/SystemMessage.js +42 -0
  194. package/lib/SystemMessage.js.map +1 -0
  195. package/lib/Time.d.ts +12 -0
  196. package/lib/Time.d.ts.map +1 -0
  197. package/lib/Time.js +38 -0
  198. package/lib/Time.js.map +1 -0
  199. package/lib/TypingIndicator/index.d.ts +5 -0
  200. package/lib/TypingIndicator/index.d.ts.map +1 -0
  201. package/lib/TypingIndicator/index.js +94 -0
  202. package/lib/TypingIndicator/index.js.map +1 -0
  203. package/lib/TypingIndicator/styles.d.ts +21 -0
  204. package/lib/TypingIndicator/styles.d.ts.map +1 -0
  205. package/lib/TypingIndicator/styles.js +22 -0
  206. package/lib/TypingIndicator/styles.js.map +1 -0
  207. package/lib/TypingIndicator/types.d.ts +6 -0
  208. package/lib/TypingIndicator/types.d.ts.map +1 -0
  209. package/lib/TypingIndicator/types.js +2 -0
  210. package/lib/TypingIndicator/types.js.map +1 -0
  211. package/lib/components/MessageReply.d.ts +29 -0
  212. package/lib/components/MessageReply.d.ts.map +1 -0
  213. package/lib/components/MessageReply.js +87 -0
  214. package/lib/components/MessageReply.js.map +1 -0
  215. package/lib/components/ReplyPreview.d.ts +17 -0
  216. package/lib/components/ReplyPreview.d.ts.map +1 -0
  217. package/lib/components/ReplyPreview.js +148 -0
  218. package/lib/components/ReplyPreview.js.map +1 -0
  219. package/lib/components/StreamingCursor.d.ts +15 -0
  220. package/lib/components/StreamingCursor.d.ts.map +1 -0
  221. package/lib/components/StreamingCursor.js +16 -0
  222. package/lib/components/StreamingCursor.js.map +1 -0
  223. package/lib/components/TouchableOpacity.d.ts +9 -0
  224. package/lib/components/TouchableOpacity.d.ts.map +1 -0
  225. package/lib/components/TouchableOpacity.js +47 -0
  226. package/lib/components/TouchableOpacity.js.map +1 -0
  227. package/lib/hooks/useColorScheme.d.ts +8 -0
  228. package/lib/hooks/useColorScheme.d.ts.map +1 -0
  229. package/lib/hooks/useColorScheme.js +17 -0
  230. package/lib/hooks/useColorScheme.js.map +1 -0
  231. package/lib/hooks/useStreamingMessages.d.ts +42 -0
  232. package/lib/hooks/useStreamingMessages.d.ts.map +1 -0
  233. package/lib/hooks/useStreamingMessages.js +96 -0
  234. package/lib/hooks/useStreamingMessages.js.map +1 -0
  235. package/lib/hooks/useUpdateLayoutEffect.d.ts +9 -0
  236. package/lib/hooks/useUpdateLayoutEffect.d.ts.map +1 -0
  237. package/lib/hooks/useUpdateLayoutEffect.js +17 -0
  238. package/lib/hooks/useUpdateLayoutEffect.js.map +1 -0
  239. package/lib/index.d.ts +35 -0
  240. package/lib/index.d.ts.map +1 -0
  241. package/lib/index.js +34 -0
  242. package/lib/index.js.map +1 -0
  243. package/lib/linkParser.d.ts +39 -0
  244. package/lib/linkParser.d.ts.map +1 -0
  245. package/lib/linkParser.js +154 -0
  246. package/lib/linkParser.js.map +1 -0
  247. package/lib/logging.d.ts +3 -0
  248. package/lib/logging.d.ts.map +1 -0
  249. package/lib/logging.js +5 -0
  250. package/lib/logging.js.map +1 -0
  251. package/lib/styles.d.ts +14 -0
  252. package/lib/styles.d.ts.map +1 -0
  253. package/lib/styles.js +23 -0
  254. package/lib/styles.js.map +1 -0
  255. package/lib/types.d.ts +19 -0
  256. package/lib/types.d.ts.map +1 -0
  257. package/lib/types.js +2 -0
  258. package/lib/types.js.map +1 -0
  259. package/lib/utils.d.ts +8 -0
  260. package/lib/utils.d.ts.map +1 -0
  261. package/lib/utils.js +105 -0
  262. package/lib/utils.js.map +1 -0
  263. package/package.json +119 -0
package/README.md ADDED
@@ -0,0 +1,1087 @@
1
+ <p align="center">
2
+ <a href="https://www.npmjs.com/package/@kesha-antonov/react-native-chat"><img alt="npm version" src="https://badge.fury.io/js/@kesha-antonov%2Freact-native-chat.svg"/></a>
3
+ <a href="https://www.npmjs.com/package/@kesha-antonov/react-native-chat"><img alt="npm downloads" src="https://img.shields.io/npm/dm/@kesha-antonov%2Freact-native-chat.svg"/></a>
4
+ <a href="https://github.com/kesha-antonov/react-native-chat/actions/workflows/main.yml"><img src="https://github.com/kesha-antonov/react-native-chat/actions/workflows/main.yml/badge.svg" alt="build"></a>
5
+ <img src="https://img.shields.io/badge/platforms-iOS%20%7C%20Android%20%7C%20Web-lightgrey.svg" alt="platforms">
6
+ <img src="https://img.shields.io/badge/TypeScript-supported-blue.svg" alt="TypeScript">
7
+ <img src="https://img.shields.io/badge/Expo-compatible-000020.svg" alt="Expo compatible">
8
+ </p>
9
+
10
+ <h1 align="center">React Native Chat</h1>
11
+
12
+ <p align="center">
13
+ The most complete chat UI for React Native & Web
14
+ </p>
15
+
16
+ <p align="center">
17
+ <a href="https://snack.expo.dev/@kesha-antonov/react-native-chat-playground" target="_blank">
18
+ <img src="https://img.shields.io/badge/â–ļī¸_Try_in_Browser-4630EB?style=for-the-badge&logo=expo&logoColor=white" alt="Try Chat on Expo Snack"/>
19
+ </a>
20
+ </p>
21
+
22
+ ---
23
+
24
+ ## ✨ Features
25
+
26
+ - 🤖 **[Streaming (AI) Messages](#streaming-ai-messages)** - Token-by-token streamed replies with a typing cursor and stop control
27
+ - 🎨 **[Fully Customizable](#-props-reference)** - Override any component with your own implementation
28
+ - 📎 **[Composer Actions](#actions--action-sheet)** - Attach photos, files, or trigger custom actions
29
+ - â†Šī¸ **[Reply to Messages](#reply-to-messages)** - Swipe-to-reply with reply preview and message threading
30
+ - âŽī¸ **[Load Earlier Messages](#load-earlier-messages)** - Infinite scroll with pagination support
31
+ - 📋 **[Copy to Clipboard](#copy-to-clipboard)** - Long-press messages to copy text
32
+ - 🔗 **[Smart Link Parsing](#smart-link-parsing)** - Auto-detect URLs, emails, phone numbers, hashtags, mentions
33
+ - 👤 **[Avatars](#avatars)** - User initials or custom avatar images
34
+ - 🌍 **[Localized Dates](#date--time)** - Full i18n support via Day.js
35
+ - âŒ¨ī¸ **[Keyboard Handling](#keyboard--layout)** - Smart keyboard avoidance for all platforms
36
+ - đŸ’Ŧ **[System Messages](#system-messages)** - Display system notifications in chat
37
+ - ⚡ **[Quick Replies](#quick-replies)** - Bot-style quick reply buttons
38
+ - 😀 **[Emoji Reactions](#emoji-reactions)** - Long-press to react, with reaction pills and an optional full emoji browser
39
+ - âœī¸ **[Typing Indicator](#typing-indicator)** - Show when users are typing
40
+ - ✅ **[Message Status](#message-status)** - Tick indicators for sent/delivered/read states
41
+ - âŦ‡ī¸ **[Scroll to Bottom](#scroll-to-bottom)** - Quick navigation button
42
+ - 🌐 **[Web Support](#web-react-native-web)** - Works with react-native-web
43
+ - 📱 **[Expo Support](#expo-projects)** - Easy integration with Expo projects
44
+ - 📝 **[TypeScript](#typescript)** - Complete TypeScript definitions included
45
+
46
+ <p align="center">
47
+ <img width="200" src="https://github.com/user-attachments/assets/c9da88f5-0b20-471c-8cd7-373bdb767517" />
48
+ &nbsp;&nbsp;&nbsp;&nbsp;
49
+ <img width="200" src="https://github.com/user-attachments/assets/f72b17f1-6c2e-43b5-87e7-477011aa3b07" />
50
+ &nbsp;&nbsp;&nbsp;&nbsp;
51
+ <img width="200" src="https://github.com/user-attachments/assets/86711e73-ee3c-4527-b38d-e4dab47a44fe" />
52
+ </p>
53
+
54
+ ---
55
+
56
+ <h3 align="center">Support This Project</h3>
57
+
58
+ <p align="center">
59
+ I maintain this project in my free time with no compensation. If you find it useful and want to help keep it alive, please consider sponsoring. Your support means a lot! 💖
60
+ <br><br>
61
+ <a href="https://github.com/sponsors/kesha-antonov">
62
+ <img src="https://img.shields.io/badge/Become_a_Sponsor-💖-ea4aaa?style=for-the-badge" alt="Become a Sponsor"/>
63
+ </a>
64
+ </p>
65
+
66
+ ---
67
+
68
+ ## 📖 Table of Contents
69
+
70
+ - [Features](#-features)
71
+ - [Requirements](#-requirements)
72
+ - [Installation](#-installation)
73
+ - [Migrating from react-native-gifted-chat](#-migrating-from-react-native-gifted-chat)
74
+ - [Usage](#-usage)
75
+ - [Props Reference](#-props-reference)
76
+ - [Data Structure](#-data-structure)
77
+ - [Platform Notes](#-platform-notes)
78
+ - [Example App](#-example-app)
79
+ - [Troubleshooting](#-troubleshooting)
80
+ - [Contributing](#-contributing)
81
+ - [Authors](#-authors)
82
+ - [License](#-license)
83
+
84
+ ---
85
+
86
+ ## 📋 Requirements
87
+
88
+ | Requirement | Version |
89
+ |-------------|---------|
90
+ | React Native | >= 0.70.0 |
91
+ | iOS | >= 13.4 |
92
+ | Android | API 21+ (Android 5.0) |
93
+ | Expo | SDK 50+ |
94
+ | TypeScript | >= 5.0 (optional) |
95
+
96
+ ---
97
+
98
+ ## đŸ“Ļ Installation
99
+
100
+ ### Expo Projects
101
+
102
+ ```bash
103
+ npx expo install react-native-chat react-native-reanimated react-native-gesture-handler react-native-safe-area-context react-native-keyboard-controller
104
+ ```
105
+
106
+ ### Bare React Native Projects
107
+
108
+ **Step 1:** Install the packages
109
+
110
+ Using yarn:
111
+ ```bash
112
+ yarn add react-native-chat react-native-reanimated react-native-gesture-handler react-native-safe-area-context react-native-keyboard-controller
113
+ ```
114
+
115
+ Using npm:
116
+ ```bash
117
+ npm install --save react-native-chat react-native-reanimated react-native-gesture-handler react-native-safe-area-context react-native-keyboard-controller
118
+ ```
119
+
120
+ **Step 2:** Install iOS pods
121
+
122
+ ```bash
123
+ npx pod-install
124
+ ```
125
+
126
+ **Step 3:** Configure react-native-reanimated
127
+
128
+ Follow the [react-native-reanimated installation guide](https://docs.swmansion.com/react-native-reanimated/docs/fundamentals/getting-started/#step-2-add-reanimateds-babel-plugin) to add the Babel plugin.
129
+
130
+ ---
131
+
132
+ ## 🔄 Migrating from react-native-gifted-chat
133
+
134
+ This library is a rebranded continuation of [`react-native-gifted-chat`](https://github.com/FaridSafi/react-native-gifted-chat), built from its latest `master`. **The API, props, and `IMessage` model are unchanged** - migrating is a package swap plus renaming the `GiftedChat*` identifiers.
135
+
136
+ ```bash
137
+ yarn remove react-native-gifted-chat
138
+ yarn add @kesha-antonov/react-native-chat
139
+ ```
140
+
141
+ | react-native-gifted-chat | @kesha-antonov/react-native-chat |
142
+ | --- | --- |
143
+ | `react-native-gifted-chat` | `@kesha-antonov/react-native-chat` |
144
+ | `GiftedChat` | `Chat` |
145
+ | `GiftedAvatar` | `ChatAvatar` |
146
+ | `GiftedChatContext` | `ChatContext` |
147
+ | `IMessage`, `User`, `useChatContext`, â€Ļ | unchanged |
148
+
149
+ See the full guide (codemod included) in **[docs/MIGRATION.md](docs/MIGRATION.md)**.
150
+
151
+ ---
152
+
153
+ ## 🚀 Usage
154
+
155
+ ### Basic Example
156
+
157
+ ```jsx
158
+ import React, { useState, useCallback, useEffect } from 'react'
159
+ import { Chat } from '@kesha-antonov/react-native-chat'
160
+ import { useHeaderHeight } from '@react-navigation/elements'
161
+
162
+ export function Example() {
163
+ const [messages, setMessages] = useState([])
164
+
165
+ // keyboardVerticalOffset = distance from screen top to Chat container
166
+ // useHeaderHeight() returns status bar + navigation header height
167
+ const headerHeight = useHeaderHeight()
168
+
169
+ useEffect(() => {
170
+ setMessages([
171
+ {
172
+ _id: 1,
173
+ text: 'Hello developer',
174
+ createdAt: new Date(),
175
+ user: {
176
+ _id: 2,
177
+ name: 'John Doe',
178
+ avatar: 'https://placeimg.com/140/140/any',
179
+ },
180
+ },
181
+ ])
182
+ }, [])
183
+
184
+ const onSend = useCallback((messages = []) => {
185
+ setMessages(previousMessages =>
186
+ Chat.append(previousMessages, messages),
187
+ )
188
+ }, [])
189
+
190
+ return (
191
+ <Chat
192
+ messages={messages}
193
+ onSend={messages => onSend(messages)}
194
+ user={{
195
+ _id: 1,
196
+ }}
197
+ keyboardAvoidingViewProps={{ keyboardVerticalOffset: headerHeight }}
198
+ />
199
+ )
200
+ }
201
+ ```
202
+
203
+ > **💡 Tip:** Check out more examples in the [`example`](example) directory including Slack-style messages, quick replies, and custom components.
204
+
205
+ ---
206
+
207
+ ## 📊 Data Structure
208
+
209
+ Messages, system messages, and quick replies follow the structure defined in [Models.ts](src/Models.ts).
210
+
211
+ <details>
212
+ <summary><strong>Message Object Structure</strong></summary>
213
+
214
+ ```typescript
215
+ interface IMessage {
216
+ _id: string | number
217
+ text: string
218
+ createdAt: Date | number
219
+ user: User
220
+ image?: string
221
+ video?: string
222
+ audio?: string
223
+ system?: boolean
224
+ sent?: boolean
225
+ received?: boolean
226
+ pending?: boolean
227
+ /** True while the text is still streaming in (shows a typing cursor) */
228
+ streaming?: boolean
229
+ quickReplies?: QuickReplies
230
+ replyMessage?: ReplyMessage
231
+ reactions?: MessageReaction[]
232
+ location?: {
233
+ latitude: number
234
+ longitude: number
235
+ }
236
+ }
237
+
238
+ interface ReplyMessage {
239
+ _id: string | number
240
+ text: string
241
+ user: User
242
+ image?: string
243
+ audio?: string
244
+ }
245
+
246
+ interface MessageReaction {
247
+ emoji: string
248
+ userIds: (string | number)[]
249
+ }
250
+
251
+ interface User {
252
+ _id: string | number
253
+ name?: string
254
+ avatar?: string | number | (() => React.ReactNode)
255
+ }
256
+ ```
257
+
258
+ </details>
259
+
260
+ ---
261
+
262
+ ## 📖 Props Reference
263
+
264
+ ### Core Configuration
265
+
266
+ - **`messages`** _(Array)_ - Messages to display
267
+ - **`user`** _(Object)_ - User sending the messages: `{ _id, name, avatar }`
268
+ - **`onSend`** _(Function)_ - Callback when sending a message
269
+ - **`messageIdGenerator`** _(Function)_ - Generate an id for new messages. Defaults to a simple random string generator.
270
+ - **`locale`** _(String)_ - Locale to localize the dates. You need first to import the locale you need (ie. `require('dayjs/locale/de')` or `import 'dayjs/locale/fr'`)
271
+ - **`colorScheme`** _('light' | 'dark')_ - Force color scheme (light/dark mode). When set to `'light'` or `'dark'`, it overrides the system color scheme. When `undefined`, it uses the system color scheme. Default is `undefined`.
272
+
273
+ ### Refs
274
+
275
+ - **`messagesContainerRef`** _(FlatList ref)_ - Ref to the flatlist
276
+ - **`textInputRef`** _(TextInput ref)_ - Ref to the text input
277
+
278
+ ### Keyboard & Layout
279
+
280
+ - **`keyboardProviderProps`** _(Object)_ - Props to be passed to the [`KeyboardProvider`](https://kirillzyusko.github.io/react-native-keyboard-controller/docs/api/keyboard-provider) for keyboard handling. Default values:
281
+ - `statusBarTranslucent: true` - Required on Android for correct keyboard height calculation when status bar is translucent (edge-to-edge mode)
282
+ - `navigationBarTranslucent: true` - Required on Android for correct keyboard height calculation when navigation bar is translucent (edge-to-edge mode)
283
+ - **`keyboardAvoidingViewProps`** _(Object)_ - Props to be passed to the [`KeyboardAvoidingView`](https://kirillzyusko.github.io/react-native-keyboard-controller/docs/api/components/keyboard-avoiding-view). See **keyboardVerticalOffset** below for proper keyboard handling.
284
+ - **`isAlignedTop`** _(Boolean)_ Controls whether or not the message bubbles appear at the top of the chat (Default is false - bubbles align to bottom)
285
+ - **`isInverted`** _(Bool)_ - Reverses display order of `messages`; default is `true`
286
+
287
+ #### Understanding `keyboardVerticalOffset`
288
+
289
+ The [`keyboardVerticalOffset`](https://kirillzyusko.github.io/react-native-keyboard-controller/docs/api/components/keyboard-avoiding-view#keyboardverticaloffset) tells the KeyboardAvoidingView where its container starts relative to the top of the screen. This is essential when Chat is not positioned at the very top of the screen (e.g., when you have a navigation header).
290
+
291
+ **Default value:** `insets.top` (status bar height from `useSafeAreaInsets()`). This works correctly only when Chat fills the entire screen without a navigation header. If you have a navigation header, you need to pass the correct offset via `keyboardAvoidingViewProps`.
292
+
293
+ **What the value means:** The offset equals the distance (in points) from the top of the screen to the top of your Chat container. This typically includes:
294
+ - Status bar height
295
+ - Navigation header height (on iOS, `useHeaderHeight()` already includes status bar)
296
+
297
+ **How to use:**
298
+
299
+ ```jsx
300
+ import { useHeaderHeight } from '@react-navigation/elements'
301
+
302
+ function ChatScreen() {
303
+ // useHeaderHeight() returns status bar + navigation header height on iOS
304
+ const headerHeight = useHeaderHeight()
305
+
306
+ return (
307
+ <Chat
308
+ keyboardAvoidingViewProps={{ keyboardVerticalOffset: headerHeight }}
309
+ // ... other props
310
+ />
311
+ )
312
+ }
313
+ ```
314
+
315
+ > **Note:** `useHeaderHeight()` requires your chat component to be rendered inside a proper navigation screen (not conditional rendering). If it returns `0`, ensure your chat screen is a real navigation screen with a visible header.
316
+
317
+ **Why this matters:** Without the correct offset, the keyboard may overlap the input field or leave extra space. The KeyboardAvoidingView uses this value to calculate how much to shift the content when the keyboard appears.
318
+
319
+ ### Text Input & Composer
320
+
321
+ - **`text`** _(String)_ - Input text; default is `undefined`, but if specified, it will override Chat's internal state. Useful for managing text state outside of Chat (e.g. with Redux). Don't forget to implement `textInputProps.onChangeText` to update the text state.
322
+ - **`initialText`** _(String)_ - Initial text to display in the input field
323
+ - **`isSendButtonAlwaysVisible`** _(Bool)_ - Always show send button in input text composer; default `false`, show only when text input is not empty
324
+ - **`isTextOptional`** _(Bool)_ - Allow sending messages without text (useful for media-only messages); default `false`. Use with `isSendButtonAlwaysVisible` for media attachments.
325
+ - **`minComposerHeight`** _(Object)_ - Custom min-height of the composer.
326
+ - **`maxComposerHeight`** _(Object)_ - Custom max height of the composer.
327
+ - **`minInputToolbarHeight`** _(Integer)_ - Minimum height of the input toolbar; default is `44`
328
+ - **`renderInputToolbar`** _(Component | Function)_ - Custom message composer container
329
+ - **`renderComposer`** _(Component | Function)_ - Custom text input message composer
330
+ - **`renderSend`** _(Component | Function)_ - Custom send button; you can pass children to the original `Send` component quite easily, for example, to use a custom icon ([example](https://github.com/kesha-antonov/react-native-chat/pull/487))
331
+ - **`renderActions`** _(Component | Function)_ - Custom action button on the left of the message composer
332
+ - **`renderAccessory`** _(Component | Function)_ - Custom second line of actions below the message composer
333
+ - **`textInputProps`** _(Object)_ - props to be passed to the [`<TextInput>`](https://reactnative.dev/docs/textinput).
334
+
335
+ ### Actions & Action Sheet
336
+
337
+ - **`onPressActionButton`** _(Function)_ - Callback when the Action button is pressed (if set, the default `actionSheet` will not be used)
338
+ - **`actionSheet`** _(Function)_ - Custom action sheet interface for showing action options
339
+ - **`actions`** _(Array)_ - Custom action options for the input toolbar action button; array of objects with `title` (string) and `action` (function) properties
340
+ - **`actionSheetOptionTintColor`** _(String)_ - Tint color for action sheet options
341
+
342
+ ### Messages & Message Container
343
+
344
+ - **`messagesContainerStyle`** _(Object)_ - Custom style for the messages container
345
+ - **`renderMessage`** _(Component | Function)_ - Custom message container
346
+ - **`renderLoading`** _(Component | Function)_ - Render a loading view when initializing
347
+ - **`renderChatEmpty`** _(Component | Function)_ - Custom component to render in the ListView when messages are empty
348
+ - **`renderChatFooter`** _(Component | Function)_ - Custom component to render below the MessagesContainer (separate from the ListView)
349
+ - **`listProps`** _(Object)_ - Extra props to be passed to the messages [`<FlatList>`](https://reactnative.dev/docs/flatlist). Supports all FlatList props including `maintainVisibleContentPosition` for keeping scroll position when new messages arrive (useful for AI chatbots).
350
+
351
+ ### Message Bubbles & Content
352
+
353
+ - **`renderBubble`** _(Component | Function(`props: BubbleProps`))_ - Custom message bubble. Receives [BubbleProps](src/Bubble/types.ts) as parameter.
354
+ - **`renderMessageText`** _(Component | Function)_ - Custom message text
355
+ - **`renderMessageImage`** _(Component | Function)_ - Custom message image
356
+ - **`renderMessageVideo`** _(Component | Function)_ - Custom message video
357
+ - **`renderMessageAudio`** _(Component | Function)_ - Custom message audio
358
+ - **`renderCustomView`** _(Component | Function)_ - Custom view inside the bubble
359
+ - **`isCustomViewBottom`** _(Bool)_ - Determine whether renderCustomView is displayed before or after the text, image and video views; default is `false`
360
+ - **`onPressMessage`** _(Function(`context`, `message`))_ - Callback when a message bubble is pressed
361
+ - **`onLongPressMessage`** _(Function(`context`, `message`))_ - Callback when a message bubble is long-pressed; you can use this to show action sheets (e.g., copy, delete, reply)
362
+ - **`imageProps`** _(Object)_ - Extra props to be passed to the [`<Image>`](https://reactnative.dev/docs/image) component created by the default `renderMessageImage`
363
+ - **`imageStyle`** _(Object)_ - Custom style for message images
364
+ - **`videoProps`** _(Object)_ - Extra props to be passed to the video component created by the required `renderMessageVideo`
365
+ - **`messageTextProps`** _(Object)_ - Extra props to be passed to the MessageText component. Useful for customizing link parsing behavior, text styles, and matchers. Supports the following props:
366
+ - `matchers` - Custom matchers for linking message content (like URLs, phone numbers, hashtags, mentions)
367
+ - `linkStyle` - Custom style for links
368
+ - `email` - Enable/disable email parsing (default: true)
369
+ - `phone` - Enable/disable phone number parsing (default: true)
370
+ - `url` - Enable/disable URL parsing (default: true)
371
+ - `hashtag` - Enable/disable hashtag parsing (default: false)
372
+ - `mention` - Enable/disable mention parsing (default: false)
373
+ - `hashtagUrl` - Base URL for hashtags (e.g., 'https://x.com/hashtag')
374
+ - `mentionUrl` - Base URL for mentions (e.g., 'https://x.com')
375
+ - `stripPrefix` - Strip 'http://' or 'https://' from URL display (default: false)
376
+ - `TextComponent` - Custom Text component to use (e.g., from react-native-gesture-handler)
377
+
378
+ Example:
379
+
380
+ ```tsx
381
+ <Chat
382
+ messageTextProps={{
383
+ phone: false, // Disable default phone number linking
384
+ matchers: [
385
+ {
386
+ type: 'phone',
387
+ pattern: /\+?[1-9][0-9\-\(\) ]{7,}[0-9]/g,
388
+ getLinkUrl: (replacerArgs: ReplacerArgs): string => {
389
+ return replacerArgs[0].replace(/[\-\(\) ]/g, '')
390
+ },
391
+ getLinkText: (replacerArgs: ReplacerArgs): string => {
392
+ return replacerArgs[0]
393
+ },
394
+ style: styles.linkStyle,
395
+ onPress: (match: CustomMatch) => {
396
+ const url = match.getAnchorHref()
397
+
398
+ const options: {
399
+ title: string
400
+ action?: () => void
401
+ }[] = [
402
+ { title: 'Copy', action: () => setStringAsync(url) },
403
+ { title: 'Call', action: () => Linking.openURL(`tel:${url}`) },
404
+ { title: 'Send SMS', action: () => Linking.openURL(`sms:${url}`) },
405
+ { title: 'Cancel' },
406
+ ]
407
+
408
+ showActionSheetWithOptions({
409
+ options: options.map(o => o.title),
410
+ cancelButtonIndex: options.length - 1,
411
+ }, (buttonIndex?: number) => {
412
+ if (buttonIndex === undefined)
413
+ return
414
+
415
+ const option = options[buttonIndex]
416
+ option.action?.()
417
+ })
418
+ },
419
+ },
420
+ ],
421
+ linkStyle: { left: { color: 'blue' }, right: { color: 'lightblue' } },
422
+ }}
423
+ />
424
+ ```
425
+
426
+ See full example in [LinksExample](example/components/chat-examples/LinksExample.tsx)
427
+
428
+ ### Avatars
429
+
430
+ - **`renderAvatar`** _(Component | Function)_ - Custom message avatar; set to `null` to not render any avatar for the message
431
+ - **`isUserAvatarVisible`** _(Bool)_ - Whether to render an avatar for the current user; default is `false`, only show avatars for other users
432
+ - **`isAvatarVisibleForEveryMessage`** _(Bool)_ - When false, avatars will only be displayed when a consecutive message is from the same user on the same day; default is `false`
433
+ - **`onPressAvatar`** _(Function(`user`))_ - Callback when a message avatar is tapped
434
+ - **`onLongPressAvatar`** _(Function(`user`))_ - Callback when a message avatar is long-pressed
435
+ - **`isAvatarOnTop`** _(Bool)_ - Render the message avatar at the top of consecutive messages, rather than the bottom; default is `false`
436
+
437
+ ### Username
438
+
439
+ - **`isUsernameVisible`** _(Bool)_ - Indicate whether to show the user's username inside the message bubble; default is `false`
440
+ - **`renderUsername`** _(Component | Function)_ - Custom Username container
441
+
442
+ ### Date & Time
443
+
444
+ - **`timeFormat`** _(String)_ - Format to use for rendering times; default is `'LT'` (see [Day.js Format](https://day.js.org/docs/en/display/format))
445
+ - **`dateFormat`** _(String)_ - Format to use for rendering dates; default is `'D MMMM'` (see [Day.js Format](https://day.js.org/docs/en/display/format))
446
+ - **`dateFormatCalendar`** _(Object)_ - Format to use for rendering relative times; default is `{ sameDay: '[Today]' }` (see [Day.js Calendar](https://day.js.org/docs/en/plugin/calendar))
447
+ - **`renderDay`** _(Component | Function)_ - Custom day above a message
448
+ - **`dayProps`** _(Object)_ - Props to pass to the Day component:
449
+ - `containerStyle` - Custom style for the day container
450
+ - `wrapperStyle` - Custom style for the day wrapper
451
+ - `textProps` - Props to pass to the Text component (e.g., `style`, `allowFontScaling`, `numberOfLines`)
452
+ - **`renderTime`** _(Component | Function)_ - Custom time inside a message
453
+ - **`timeTextStyle`** _(Object)_ - Custom text style for time inside messages (supports left/right styles)
454
+ - **`isDayAnimationEnabled`** _(Bool)_ - Enable animated day label that appears on scroll; default is `true`
455
+
456
+ ### System Messages
457
+
458
+ - **`renderSystemMessage`** _(Component | Function)_ - Custom system message
459
+
460
+ ### Load Earlier Messages
461
+
462
+ - **`loadEarlierMessagesProps`** _(Object)_ - Props to pass to the LoadEarlierMessages component. The button is only visible when `isAvailable` is `true`. Supports the following props:
463
+ - `isAvailable` - Controls button visibility (default: false)
464
+ - `onPress` - Callback when button is pressed
465
+ - `isLoading` - Display loading indicator (default: false)
466
+ - `isInfiniteScrollEnabled` - Enable infinite scroll up when reaching the top of messages container, automatically calls `onPress` (not yet supported for web)
467
+ - `label` - Override the default "Load earlier messages" text
468
+ - `containerStyle` - Custom style for the button container
469
+ - `wrapperStyle` - Custom style for the button wrapper
470
+ - `textStyle` - Custom style for the button text
471
+ - `activityIndicatorStyle` - Custom style for the loading indicator
472
+ - `activityIndicatorColor` - Color of the loading indicator (default: 'white')
473
+ - `activityIndicatorSize` - Size of the loading indicator (default: 'small')
474
+ - **`renderLoadEarlier`** _(Component | Function)_ - Custom "Load earlier messages" button
475
+
476
+ ### Typing Indicator
477
+
478
+ - **`isTyping`** _(Bool)_ - Typing Indicator state; default `false`. If you use`renderFooter` it will override this.
479
+ - **`renderTypingIndicator`** _(Component | Function)_ - Custom typing indicator component
480
+ - **`typingIndicatorStyle`** _(StyleProp<ViewStyle>)_ - Custom style for the TypingIndicator component.
481
+ - **`renderFooter`** _(Component | Function)_ - Custom footer component on the ListView, e.g. `'User is typing...'`; see [CustomizedFeaturesExample.tsx](example/components/chat-examples/CustomizedFeaturesExample.tsx) for an example. Overrides default typing indicator that triggers when `isTyping` is true.
482
+
483
+ ### Quick Replies
484
+
485
+ See [Quick Replies example in messages.ts](example/example-expo/data/messages.ts)
486
+
487
+ - **`onQuickReply`** _(Function)_ - Callback when sending a quick reply (to backend server)
488
+ - **`renderQuickReplies`** _(Function)_ - Custom all quick reply view
489
+ - **`quickReplyStyle`** _(StyleProp<ViewStyle>)_ - Custom quick reply view style
490
+ - **`quickReplyTextStyle`** _(StyleProp<TextStyle>)_ - Custom text style for quick reply buttons
491
+ - **`quickReplyContainerStyle`** _(StyleProp<ViewStyle>)_ - Custom container style for quick replies
492
+ - **`renderQuickReplySend`** _(Function)_ - Custom quick reply **send** view
493
+
494
+ ### Reply to Messages
495
+
496
+ React Native Chat supports swipe-to-reply functionality out of the box. When enabled, users can swipe on a message to reply to it, displaying a reply preview in the input toolbar and the replied message above the new message bubble.
497
+
498
+ > **Note:** This feature uses `ReanimatedSwipeable` from `react-native-gesture-handler` and `react-native-reanimated` for smooth, performant animations.
499
+
500
+ #### Basic Usage
501
+
502
+ ```tsx
503
+ <Chat
504
+ messages={messages}
505
+ onSend={onSend}
506
+ user={{ _id: 1 }}
507
+ reply={{
508
+ swipe: {
509
+ isEnabled: true,
510
+ direction: 'left', // swipe left to reply
511
+ },
512
+ }}
513
+ />
514
+ ```
515
+
516
+ #### Reply Props (Grouped)
517
+
518
+ The `reply` prop accepts an object with the following structure:
519
+
520
+ ```typescript
521
+ interface ReplyProps<TMessage> {
522
+ // Swipe gesture configuration
523
+ swipe?: {
524
+ isEnabled?: boolean // Enable swipe-to-reply; default false
525
+ direction?: 'left' | 'right' // Swipe direction; default 'left'
526
+ onSwipe?: (message: TMessage) => void // Callback when swiped
527
+ renderAction?: ( // Custom swipe action component
528
+ progress: SharedValue<number>,
529
+ translation: SharedValue<number>,
530
+ position: 'left' | 'right'
531
+ ) => React.ReactNode
532
+ actionContainerStyle?: StyleProp<ViewStyle>
533
+ }
534
+
535
+ // Reply preview styling (above input toolbar)
536
+ previewStyle?: {
537
+ containerStyle?: StyleProp<ViewStyle>
538
+ textStyle?: StyleProp<TextStyle>
539
+ imageStyle?: StyleProp<ImageStyle>
540
+ }
541
+
542
+ // In-bubble reply styling
543
+ messageStyle?: {
544
+ containerStyle?: StyleProp<ViewStyle>
545
+ containerStyleLeft?: StyleProp<ViewStyle>
546
+ containerStyleRight?: StyleProp<ViewStyle>
547
+ textStyle?: StyleProp<TextStyle>
548
+ textStyleLeft?: StyleProp<TextStyle>
549
+ textStyleRight?: StyleProp<TextStyle>
550
+ imageStyle?: StyleProp<ImageStyle>
551
+ }
552
+
553
+ // Callbacks and state
554
+ message?: ReplyMessage // Controlled reply state
555
+ onClear?: () => void // Called when reply cleared
556
+ onPress?: (message: TMessage) => void // Called when reply preview tapped
557
+
558
+ // Custom renderers
559
+ renderPreview?: (props: ReplyPreviewProps) => React.ReactNode
560
+ renderMessageReply?: (props: MessageReplyProps) => React.ReactNode
561
+ }
562
+ ```
563
+
564
+ #### ReplyMessage Structure
565
+
566
+ When a message has a reply, it includes a `replyMessage` property:
567
+
568
+ ```typescript
569
+ interface ReplyMessage {
570
+ _id: string | number
571
+ text: string
572
+ user: User
573
+ image?: string
574
+ audio?: string
575
+ }
576
+ ```
577
+
578
+ #### Advanced Example with External State
579
+
580
+ ```tsx
581
+ const [replyMessage, setReplyMessage] = useState<ReplyMessage | null>(null)
582
+
583
+ <Chat
584
+ messages={messages}
585
+ onSend={messages => {
586
+ const newMessages = messages.map(msg => ({
587
+ ...msg,
588
+ replyMessage: replyMessage || undefined,
589
+ }))
590
+ setMessages(prev => Chat.append(prev, newMessages))
591
+ setReplyMessage(null)
592
+ }}
593
+ user={{ _id: 1 }}
594
+ reply={{
595
+ swipe: {
596
+ isEnabled: true,
597
+ direction: 'right',
598
+ onSwipe: setReplyMessage,
599
+ },
600
+ message: replyMessage,
601
+ onClear: () => setReplyMessage(null),
602
+ onPress: (msg) => scrollToMessage(msg._id),
603
+ }}
604
+ />
605
+ ```
606
+
607
+ #### Smooth Animations
608
+
609
+ The reply preview automatically animates when:
610
+ - **Appearing**: Smoothly expands from zero height with fade-in effect
611
+ - **Disappearing**: Smoothly collapses with fade-out effect
612
+ - **Content changes**: Smoothly transitions when replying to a different message
613
+
614
+ These animations use `react-native-reanimated` for 60fps performance.
615
+
616
+ ### Scroll to Bottom
617
+
618
+ - **`isScrollToBottomEnabled`** _(Bool)_ - Enables the scroll to bottom Component (Default is false)
619
+ - **`scrollToBottomComponent`** _(Function)_ - Custom Scroll To Bottom Component container
620
+ - **`scrollToBottomOffset`** _(Integer)_ - Custom Height Offset upon which to begin showing Scroll To Bottom Component (Default is 200)
621
+ - **`scrollToBottomStyle`** _(Object)_ - Custom style for Scroll To Bottom wrapper (position, bottom, right, etc.)
622
+ - **`scrollToBottomContentStyle`** _(Object)_ - Custom style for Scroll To Bottom content (size, background, shadow, etc.)
623
+
624
+ ### Maintaining Scroll Position (AI Chatbots)
625
+
626
+ For AI chat interfaces where long responses arrive and you don't want to disrupt the user's reading position, use [`maintainVisibleContentPosition`](https://reactnative.dev/docs/scrollview#maintainvisiblecontentposition) via `listProps`:
627
+
628
+ ```tsx
629
+ // Basic usage - always maintain scroll position
630
+ <Chat
631
+ listProps={{
632
+ maintainVisibleContentPosition: {
633
+ minIndexForVisible: 0,
634
+ },
635
+ }}
636
+ />
637
+
638
+ // With auto-scroll threshold - auto-scroll if within 10 pixels of newest content
639
+ <Chat
640
+ listProps={{
641
+ maintainVisibleContentPosition: {
642
+ minIndexForVisible: 0,
643
+ autoscrollToTopThreshold: 10,
644
+ },
645
+ }}
646
+ />
647
+
648
+ // Conditionally enable based on scroll state (recommended for chatbots)
649
+ const [isScrolledUp, setIsScrolledUp] = useState(false)
650
+
651
+ <Chat
652
+ listProps={{
653
+ onScroll: (event) => {
654
+ setIsScrolledUp(event.contentOffset.y > 50)
655
+ },
656
+ maintainVisibleContentPosition: isScrolledUp
657
+ ? { minIndexForVisible: 0, autoscrollToTopThreshold: 10 }
658
+ : undefined,
659
+ }}
660
+ />
661
+ ```
662
+
663
+ ### Streaming (AI) Messages
664
+
665
+ Render AI assistant replies token-by-token. The library batches incoming chunks with `requestAnimationFrame` (one render per frame, only the streaming bubble re-renders) and shows a blinking caret while a message is still streaming.
666
+
667
+ - **`IMessage.streaming`** - flag a message as streaming (shows the caret)
668
+ - **`Chat.updateMessage(messages, id, patch)`** - immutable per-message update, cheap enough for per-token appends
669
+ - **`useStreamingMessages(...)`** - owns the message list, rAF-batches `push()`, and supports stop via `AbortController`
670
+
671
+ ```tsx
672
+ import { useCallback } from 'react'
673
+ import { Chat, IMessage, useStreamingMessages } from '@kesha-antonov/react-native-chat'
674
+
675
+ function Bot () {
676
+ const { messages, append, startStream, isStreaming, stop } = useStreamingMessages<IMessage>()
677
+
678
+ const onSend = useCallback((newMessages: IMessage[] = []) => {
679
+ append(newMessages[0]) // show the user's message
680
+ const stream = startStream({ user: { _id: 2, name: 'Assistant' } }) // empty streaming bubble
681
+
682
+ runMyModel(newMessages[0].text, {
683
+ signal: stream.signal, // aborts when stop() is called
684
+ onToken: token => stream.push(token), // batched, one render per frame
685
+ onDone: () => stream.done(), // clears the streaming flag
686
+ })
687
+ }, [append, startStream])
688
+
689
+ return <Chat messages={messages} onSend={onSend} user={{ _id: 1 }} />
690
+ }
691
+ ```
692
+
693
+ See **[docs/STREAMING.md](./docs/STREAMING.md)** for the full hook API and a real Claude streaming adapter (via a backend proxy). A runnable demo lives in `example/components/chat-examples/AIBotExample.tsx`.
694
+
695
+ ### Emoji Reactions
696
+
697
+ Long-press a message to open a quick emoji picker; selected reactions render as pills below the bubble and toggle on tap. The core ships a lightweight quick picker (built on `react-native-gesture-handler` and `react-native-reanimated`, no extra dependencies). A full emoji browser is optional and demonstrated in the example app via the `renderReactionPicker` override.
698
+
699
+ <p align="center">
700
+ <img width="200" src="https://raw.githubusercontent.com/kesha-antonov/react-native-chat/main/media/reactions-picker.png" />
701
+ &nbsp;&nbsp;
702
+ <img width="200" src="https://raw.githubusercontent.com/kesha-antonov/react-native-chat/main/media/reactions-pills.png" />
703
+ &nbsp;&nbsp;
704
+ <img width="200" src="https://raw.githubusercontent.com/kesha-antonov/react-native-chat/main/media/reactions-emoji-browser.png" />
705
+ </p>
706
+
707
+ Store reactions on each message as a `reactions` array, then enable the feature and handle the toggle. Reaction state is owned by you, so it works with any backend:
708
+
709
+ ```tsx
710
+ interface IChatMessage extends IMessage {
711
+ reactions?: MessageReaction[] // { emoji: string, userIds: (string | number)[] }[]
712
+ }
713
+
714
+ const CURRENT_USER_ID = 1
715
+
716
+ const handleReactionPress = useCallback((message: IChatMessage, emoji: string) => {
717
+ setMessages(prev =>
718
+ prev.map(m => {
719
+ if (m._id !== message._id)
720
+ return m
721
+
722
+ const existing = (m.reactions ?? []).find(r => r.emoji === emoji)
723
+ if (!existing)
724
+ return { ...m, reactions: [...(m.reactions ?? []), { emoji, userIds: [CURRENT_USER_ID] }] }
725
+
726
+ const userIds = existing.userIds.includes(CURRENT_USER_ID)
727
+ ? existing.userIds.filter(id => id !== CURRENT_USER_ID)
728
+ : [...existing.userIds, CURRENT_USER_ID]
729
+
730
+ return {
731
+ ...m,
732
+ reactions: userIds.length === 0
733
+ ? (m.reactions ?? []).filter(r => r.emoji !== emoji)
734
+ : (m.reactions ?? []).map(r => (r.emoji === emoji ? { ...r, userIds } : r)),
735
+ }
736
+ })
737
+ )
738
+ }, [])
739
+
740
+ <Chat
741
+ messages={messages}
742
+ onSend={onSend}
743
+ user={{ _id: CURRENT_USER_ID }}
744
+ reactions={{
745
+ isEnabled: true,
746
+ onReactionPress: handleReactionPress,
747
+ // Optional: provide a richer picker (e.g. a full emoji browser).
748
+ // See example/components/chat-examples/ReactionsExample.tsx
749
+ // renderReactionPicker: props => <MyEmojiPicker {...props} />,
750
+ }}
751
+ />
752
+ ```
753
+
754
+ #### Reactions Props (Grouped)
755
+
756
+ The `reactions` prop accepts:
757
+
758
+ - **`isEnabled`** _(Bool)_ - Enable emoji reactions (default `false`)
759
+ - **`emojis`** _(String[])_ - Emojis shown in the quick picker (default `['👍', 'â¤ī¸', '😂', '😮', 'đŸ˜ĸ', '👎']`)
760
+ - **`onReactionPress`** _(Function)_ - `(message, emoji) => void` called when an emoji is selected or a pill is tapped. Toggle logic is left to you
761
+ - **`renderReactions`** _(Function)_ - Override the reactions-display component rendered below the bubble
762
+ - **`renderReactionPicker`** _(Function)_ - Override the picker shown on long-press (use for a full emoji browser)
763
+ - **`containerStyle`**, **`reactionStyle`**, **`reactionActiveStyle`**, **`reactionTextStyle`**, **`reactionCountStyle`** - Styles for the reaction pills
764
+ - **`pickerContainerStyle`**, **`pickerEmojiStyle`** - Styles for the quick picker
765
+
766
+ ### Smart Link Parsing
767
+
768
+ Message text is automatically scanned for URLs, emails, and phone numbers; hashtags and mentions are opt-in. Configure it via `messageTextProps`:
769
+
770
+ ```tsx
771
+ <Chat
772
+ messageTextProps={{
773
+ url: true, // default true
774
+ email: true, // default true
775
+ phone: true, // default true
776
+ hashtag: true, // default false
777
+ mention: true, // default false
778
+ hashtagUrl: 'https://example.com/hashtag',
779
+ mentionUrl: 'https://example.com',
780
+ linkStyle: { left: { color: '#1d9bf0' }, right: { color: '#fff' } },
781
+ onPress: (message, url, type) => {
782
+ // type: 'url' | 'email' | 'phone' | 'mention' | 'hashtag'
783
+ Linking.openURL(url)
784
+ },
785
+ }}
786
+ />
787
+ ```
788
+
789
+ For full control, pass custom `matchers` (`{ type, pattern, getLinkUrl?, getLinkText?, renderLink?, onPress? }[]`) to add or override patterns. See the Links example in the [example app](#-example-app).
790
+
791
+ ### Copy to Clipboard
792
+
793
+ Long-press handling is exposed via `onLongPressMessage`. Chat wraps [`@expo/react-native-action-sheet`](https://github.com/expo/react-native-action-sheet), so you can show a "Copy Text" action sheet and copy with the clipboard library of your choice:
794
+
795
+ ```tsx
796
+ import { useActionSheet } from '@expo/react-native-action-sheet'
797
+ import { setStringAsync } from 'expo-clipboard'
798
+
799
+ const { showActionSheetWithOptions } = useActionSheet()
800
+
801
+ <Chat
802
+ onLongPressMessage={(_context, message) => {
803
+ showActionSheetWithOptions(
804
+ { options: ['Copy Text', 'Cancel'], cancelButtonIndex: 1 },
805
+ buttonIndex => {
806
+ if (buttonIndex === 0)
807
+ setStringAsync(message.text)
808
+ }
809
+ )
810
+ }}
811
+ />
812
+ ```
813
+
814
+ ### Message Status
815
+
816
+ Set `sent`, `received`, or `pending` on a message to show its delivery status. By default these render as tick indicators next to the timestamp (`✓` sent, `✓✓` received, `🕓` pending):
817
+
818
+ ```tsx
819
+ const message: IMessage = {
820
+ _id: 1,
821
+ text: 'Delivered!',
822
+ createdAt: new Date(),
823
+ user: { _id: 1 },
824
+ sent: true,
825
+ received: true,
826
+ }
827
+ ```
828
+
829
+ Customize the indicators with `renderTicks` (full override) or `tickStyle` (style only):
830
+
831
+ ```tsx
832
+ <Chat
833
+ renderTicks={message => (message.received ? <MyReadIcon /> : null)}
834
+ tickStyle={{ color: '#1d9bf0' }}
835
+ />
836
+ ```
837
+
838
+ ### TypeScript
839
+
840
+ Chat ships complete type definitions and is generic over your message type. Extend `IMessage` to add custom fields and everything stays typed end to end:
841
+
842
+ ```tsx
843
+ import { Chat, IMessage } from '@kesha-antonov/react-native-chat'
844
+
845
+ interface MyMessage extends IMessage {
846
+ reactions?: { emoji: string, userIds: (string | number)[] }[]
847
+ }
848
+
849
+ <Chat<MyMessage>
850
+ messages={messages}
851
+ onSend={msgs => {/* msgs is typed as MyMessage[] */}}
852
+ user={{ _id: 1 }}
853
+ />
854
+ ```
855
+
856
+ ---
857
+
858
+
859
+ ---
860
+
861
+ ## 📱 Platform Notes
862
+
863
+ ### Android
864
+
865
+ <details>
866
+ <summary><strong>Keyboard configuration</strong></summary>
867
+
868
+ If you are using Create React Native App / Expo, no Android specific installation steps are required. Otherwise, we recommend modifying your project configuration:
869
+
870
+ Make sure you have `android:windowSoftInputMode="adjustResize"` in your `AndroidManifest.xml`:
871
+
872
+ ```xml
873
+ <activity
874
+ android:name=".MainActivity"
875
+ android:label="@string/app_name"
876
+ android:windowSoftInputMode="adjustResize"
877
+ android:configChanges="keyboard|keyboardHidden|orientation|screenSize">
878
+ ```
879
+
880
+ For **Expo**, you can append `KeyboardAvoidingView` after Chat (Android only):
881
+
882
+ ```jsx
883
+ <View style={{ flex: 1 }}>
884
+ <Chat />
885
+ {Platform.OS === 'android' && <KeyboardAvoidingView behavior="padding" />}
886
+ </View>
887
+ ```
888
+
889
+ </details>
890
+
891
+ ### Web (react-native-web)
892
+
893
+ <details>
894
+ <summary><strong>With create-react-app</strong></summary>
895
+
896
+ 1. Install react-app-rewired: `yarn add -D react-app-rewired`
897
+ 2. Create `config-overrides.js`:
898
+
899
+ ```js
900
+ module.exports = function override(config, env) {
901
+ config.module.rules.push({
902
+ test: /\.js$/,
903
+ exclude: /node_modules[/\\](?!react-native-chat)/,
904
+ use: {
905
+ loader: 'babel-loader',
906
+ options: {
907
+ babelrc: false,
908
+ configFile: false,
909
+ presets: [
910
+ ['@babel/preset-env', { useBuiltIns: 'usage' }],
911
+ '@babel/preset-react',
912
+ ],
913
+ plugins: ['@babel/plugin-proposal-class-properties'],
914
+ },
915
+ },
916
+ })
917
+ return config
918
+ }
919
+ ```
920
+
921
+ </details>
922
+
923
+ ---
924
+
925
+ ## đŸ§Ē Testing
926
+
927
+ <details>
928
+ <summary><strong>Triggering layout events in tests</strong></summary>
929
+
930
+ `TEST_ID` is exported as constants that can be used in your testing library of choice.
931
+
932
+ React Native Chat uses `onLayout` to determine the height of the chat container. To trigger `onLayout` during your tests:
933
+
934
+ ```typescript
935
+ const WIDTH = 200
936
+ const HEIGHT = 2000
937
+
938
+ const loadingWrapper = getByTestId(TEST_ID.LOADING_WRAPPER)
939
+ fireEvent(loadingWrapper, 'layout', {
940
+ nativeEvent: {
941
+ layout: {
942
+ width: WIDTH,
943
+ height: HEIGHT,
944
+ },
945
+ },
946
+ })
947
+ ```
948
+
949
+ </details>
950
+
951
+ ---
952
+
953
+ ## đŸ“Ļ Example App
954
+
955
+ The repository includes a comprehensive example app demonstrating all features:
956
+
957
+ ```bash
958
+ # Clone and install
959
+ git clone https://github.com/kesha-antonov/react-native-chat.git
960
+ cd react-native-chat/example
961
+ yarn install
962
+
963
+ # Run on iOS
964
+ npx expo run:ios
965
+
966
+ # Run on Android
967
+ npx expo run:android
968
+
969
+ # Run on Web
970
+ npx expo start --web
971
+ ```
972
+
973
+ The example app showcases:
974
+ - đŸ’Ŧ Basic chat functionality
975
+ - 🎨 Custom message bubbles and avatars
976
+ - â†Šī¸ Reply to messages with swipe gesture
977
+ - ⚡ Quick replies (bot-style)
978
+ - âœī¸ Typing indicators
979
+ - 📎 Attachment actions
980
+ - 🔗 Link parsing and custom matchers
981
+ - 🌐 Web compatibility
982
+
983
+ ---
984
+
985
+ ## ❓ Troubleshooting
986
+
987
+ <details>
988
+ <summary><strong>TextInput is hidden on Android</strong></summary>
989
+
990
+ Make sure you have `android:windowSoftInputMode="adjustResize"` in your `AndroidManifest.xml`. See [Android configuration](#android) above.
991
+
992
+ </details>
993
+
994
+ <details>
995
+ <summary><strong>How to set Bubble color for each user?</strong></summary>
996
+
997
+ See [this issue](https://github.com/kesha-antonov/react-native-chat/issues/672) for examples.
998
+
999
+ </details>
1000
+
1001
+ <details>
1002
+ <summary><strong>How to customize InputToolbar styles?</strong></summary>
1003
+
1004
+ See [this issue](https://github.com/kesha-antonov/react-native-chat/issues/662) for examples.
1005
+
1006
+ </details>
1007
+
1008
+ <details>
1009
+ <summary><strong>How to manually dismiss the keyboard?</strong></summary>
1010
+
1011
+ See [this issue](https://github.com/kesha-antonov/react-native-chat/issues/647) for examples.
1012
+
1013
+ </details>
1014
+
1015
+ <details>
1016
+ <summary><strong>How to use renderLoading?</strong></summary>
1017
+
1018
+ See [this issue](https://github.com/kesha-antonov/react-native-chat/issues/298) for examples.
1019
+
1020
+ </details>
1021
+
1022
+ ---
1023
+
1024
+ ## 🤔 Have a Question?
1025
+
1026
+ 1. Check this README first
1027
+ 2. Search [existing issues](https://github.com/kesha-antonov/react-native-chat/issues)
1028
+ 3. Ask on [StackOverflow](https://stackoverflow.com/questions/tagged/kesha-antonov/react-native-chat)
1029
+ 4. Open a new issue if needed
1030
+
1031
+ ---
1032
+
1033
+ ## 🤝 Contributing
1034
+
1035
+ Contributions are welcome! Please feel free to submit a Pull Request.
1036
+
1037
+ 1. Fork the repository
1038
+ 2. Create your feature branch (`git checkout -b feature/amazing-feature`)
1039
+ 3. Install dependencies (`yarn install`)
1040
+ 4. Make your changes
1041
+ 5. Run tests (`yarn test`)
1042
+ 6. Run linting (`yarn lint`)
1043
+ 7. Build the library (`yarn build`)
1044
+ 8. Commit your changes (`git commit -m 'Add amazing feature'`)
1045
+ 9. Push to the branch (`git push origin feature/amazing-feature`)
1046
+ 10. Open a Pull Request
1047
+
1048
+ ### Development Setup
1049
+
1050
+ ```bash
1051
+ # Install dependencies
1052
+ yarn install
1053
+
1054
+ # Build the library
1055
+ yarn build
1056
+
1057
+ # Run tests
1058
+ yarn test
1059
+
1060
+ # Run linting
1061
+ yarn lint
1062
+
1063
+ # Full validation
1064
+ yarn prepublishOnly
1065
+ ```
1066
+
1067
+ ---
1068
+
1069
+ ## đŸ‘Ĩ Authors
1070
+
1071
+ Based on [FaridSafi/react-native-chat](https://github.com/FaridSafi/react-native-chat), which is no longer actively maintained.
1072
+
1073
+ **Maintainer:** [Kesha Antonov](https://github.com/kesha-antonov)
1074
+
1075
+ > I maintained the original project solo for 2 years before deciding to continue development in this repository. If you find this library useful, please consider [becoming a sponsor](https://github.com/sponsors/kesha-antonov) to support continued development. 💖
1076
+
1077
+ ---
1078
+
1079
+ ## 📄 License
1080
+
1081
+ [MIT](LICENSE)
1082
+
1083
+ ---
1084
+
1085
+ <p align="center">
1086
+ <sub>Built with â¤ī¸ by the React Native community</sub>
1087
+ </p>