diff --git a/src/data/nav/chat.ts b/src/data/nav/chat.ts
index af612eee13..ced8cf5923 100644
--- a/src/data/nav/chat.ts
+++ b/src/data/nav/chat.ts
@@ -295,9 +295,49 @@ export default {
],
},
{
- link: 'https://sdk.ably.com/builds/ably/ably-chat-js/main/typedoc/modules/chat-react.html',
- name: 'React SDK',
- external: true,
+ name: 'React',
+ pages: [
+ {
+ link: '/docs/chat/api/react/providers',
+ name: 'Providers',
+ },
+ {
+ link: '/docs/chat/api/react/use-chat-client',
+ name: 'useChatClient',
+ },
+ {
+ link: '/docs/chat/api/react/use-chat-connection',
+ name: 'useChatConnection',
+ },
+ {
+ link: '/docs/chat/api/react/use-room',
+ name: 'useRoom',
+ },
+ {
+ link: '/docs/chat/api/react/use-messages',
+ name: 'useMessages',
+ },
+ {
+ link: '/docs/chat/api/react/use-presence',
+ name: 'usePresence',
+ },
+ {
+ link: '/docs/chat/api/react/use-presence-listener',
+ name: 'usePresenceListener',
+ },
+ {
+ link: '/docs/chat/api/react/use-occupancy',
+ name: 'useOccupancy',
+ },
+ {
+ link: '/docs/chat/api/react/use-typing',
+ name: 'useTyping',
+ },
+ {
+ link: '/docs/chat/api/react/use-room-reactions',
+ name: 'useRoomReactions',
+ },
+ ],
},
{
link: 'https://sdk.ably.com/builds/ably/ably-chat-kotlin/main/dokka/',
diff --git a/src/pages/docs/chat/api/index.mdx b/src/pages/docs/chat/api/index.mdx
index 7d4ca281df..67a2c69aa2 100644
--- a/src/pages/docs/chat/api/index.mdx
+++ b/src/pages/docs/chat/api/index.mdx
@@ -11,7 +11,7 @@ This section of the documentation contains the API references for Ably Chat.
The following API references are available:
* [JavaScript](/docs/chat/api/javascript/chat-client)
-* [React Hooks](https://sdk.ably.com/builds/ably/ably-chat-js/main/typedoc/modules/chat-react.html)
+* [React](/docs/chat/api/react/providers)
* [Kotlin (JVM & Android)](https://sdk.ably.com/builds/ably/ably-chat-kotlin/main/dokka/)
* [Swift](https://sdk.ably.com/builds/ably/ably-chat-swift/main/AblyChat/documentation/ablychat/)
diff --git a/src/pages/docs/chat/api/react/providers.mdx b/src/pages/docs/chat/api/react/providers.mdx
new file mode 100644
index 0000000000..5326cbb2a9
--- /dev/null
+++ b/src/pages/docs/chat/api/react/providers.mdx
@@ -0,0 +1,194 @@
+---
+title: Providers
+meta_description: "API reference for the ChatClientProvider and ChatRoomProvider components in the Ably Chat React SDK."
+meta_keywords: "Ably Chat SDK, React, ChatClientProvider, ChatRoomProvider, providers, context, hooks"
+---
+
+The Ably Chat React SDK provides two context providers that supply chat functionality to your component tree. All chat hooks must be used within these providers.
+
+An API key is required to authenticate with Ably. API keys are used either to authenticate directly with Ably using basic authentication, or to generate tokens for untrusted clients using [JWT authentication](/docs/auth/token#jwt). Authenticate an `Ably.Realtime` Pub/Sub client and then pass it to the `ChatClientProvider`.
+
+
+
+
+```react
+import * as Ably from 'ably';
+import { ChatClient } from '@ably/chat';
+import { ChatClientProvider, ChatRoomProvider } from '@ably/chat/react';
+
+const realtimeClient = new Ably.Realtime({ key: '{{API_KEY}}', clientId: 'my-client-id' });
+const chatClient = new ChatClient(realtimeClient);
+
+function App() {
+ return (
+
+
+ {/* Chat hooks can be used here */}
+
+
+ );
+}
+```
+
+
+
+
+## ChatClientProvider
+
+Provides a `ChatClient` instance to all descendant components via React context. All chat hooks, including [`useChatClient`](/docs/chat/api/react/use-chat-client) and [`useChatConnection`](/docs/chat/api/react/use-chat-connection), require this provider to be present in the component tree.
+
+The `client` property should be memoized to prevent unnecessary context updates. The provider manages room reference counting internally, only detaching rooms when no references remain.
+
+### Properties
+
+
+
+| Property | Required | Description | Type |
+| --- | --- | --- | --- |
+| client | Required | An instance of the ChatClient. | ChatClient |
+| children | Optional | Child components that will have access to the chat client context. | ReactNode or ReactNode[] |
+
+
+
+## ChatRoomProvider
+
+Provides room context to descendant components. All room-level hooks such as [`useMessages`](/docs/chat/api/react/use-messages), [`usePresence`](/docs/chat/api/react/use-presence), and [`useTyping`](/docs/chat/api/react/use-typing) require this provider.
+
+The provider automatically handles room attachment and detachment. Multiple providers for the same room with the same options share the same underlying room instance through reference counting.
+
+### Properties
+
+
+
+| Property | Required | Description | Type |
+| --- | --- | --- | --- |
+| name | Required | The name of the room. | String |
+| options | Optional | Options to use when creating the room. Must be memoized to prevent unnecessary room recreations. Room options are immutable after creation; differing options for the same room name cause errors. |
|
+| children | Optional | Child components that will have access to the room context. | ReactNode or ReactNode[] |
+
+
+
+| Property | Required | Description | Type |
+| --- | --- | --- | --- |
+| heartbeatThrottleMs | Optional | Minimum time in milliseconds between consecutive typing started events. The first call emits immediately; later calls are no-ops until the interval has elapsed. Calling typing.stop resets the interval. Default 10000. | Number |
+
+
+
+
+
+| Property | Required | Description | Type |
+| --- | --- | --- | --- |
+| enableEvents | Optional | Whether the client receives presence events from the server. Can be disabled if presence is used but this client does not need the messages. Default true. | Boolean |
+
+
+
+
+
+| Property | Required | Description | Type |
+| --- | --- | --- | --- |
+| enableEvents | Optional | Whether to receive occupancy events. Enabling this increases message volume as the server sends additional updates for occupancy changes. Default false. | Boolean |
+
+
+
+
+
+| Property | Required | Description | Type |
+| --- | --- | --- | --- |
+| rawMessageReactions | Optional | Whether to receive raw individual message reactions from the realtime channel. Reaction summaries remain available regardless of this setting. Default false. | Boolean |
+| defaultMessageReactionType | Optional | The default message reaction type for sending reactions. Individual types can still be specified via the send method parameter. The default is `Distinct`. |
|
+
+
+
+
+
+| Value | Description |
+| --- | --- |
+| Distinct | Allows at most one reaction of each type per client per message. Duplicates are not counted in the summary. Similar to reactions on Slack. The value is `distinct`. |
+| Multiple | Allows any number of reactions, including repeats, counted in the summary. The reaction payload includes a count. Similar to the clap feature on Medium. The value is `multiple`. |
+| Unique | Allows at most one reaction per client per message. If a client reacts again, only the second reaction is counted. Similar to reactions on iMessage or WhatsApp. The value is `unique`. |
+
+
+
+## ErrorInfo
+
+A standardized, generic Ably error object that contains an Ably-specific status code, and a generic HTTP status code. All errors returned from Ably are compatible with the `ErrorInfo` structure.
+
+
+
+| Property | Description | Type |
+| --- | --- | --- |
+| code | Ably-specific error code. | Number |
+| statusCode | HTTP status code corresponding to this error, where applicable. | Number |
+| message | Additional information about the error. | String |
+| cause | The underlying cause of the error, where applicable. | String, ErrorInfo, or Error |
+| detail | Optional map of string key-value pairs containing structured metadata associated with the error. | `Record` or Undefined |
+
+
+
+## DiscontinuityListener
+
+A callback to detect and respond to discontinuities in the event stream. Discontinuities occur when the client may have missed events due to connectivity issues.
+
+
+
+| Parameter | Description | Type |
+| --- | --- | --- |
+| error | An error providing context about why the discontinuity occurred. | [ErrorInfo](#errorInfo) |
+
+
+
+## Example
+
+
+```react
+import * as Ably from 'ably';
+import { ChatClient } from '@ably/chat';
+import { ChatClientProvider, ChatRoomProvider } from '@ably/chat/react';
+import { useMemo } from 'react';
+
+// Create clients outside of components
+const realtimeClient = new Ably.Realtime({
+ key: '{{API_KEY}}',
+ clientId: 'user-123'
+});
+const chatClient = new ChatClient(realtimeClient);
+
+function App() {
+ // Memoize room options to prevent unnecessary recreations
+ const roomOptions = useMemo(() => ({
+ typing: { heartbeatThrottleMs: 5000 },
+ occupancy: { enableEvents: true },
+ }), []);
+
+ return (
+
+
+
+
+
+ );
+}
+
+function ChatRoom() {
+ // All chat hooks can be used here
+ return
Chat room content
;
+}
+```
+
diff --git a/src/pages/docs/chat/api/react/use-chat-client.mdx b/src/pages/docs/chat/api/react/use-chat-client.mdx
new file mode 100644
index 0000000000..723c742ff1
--- /dev/null
+++ b/src/pages/docs/chat/api/react/use-chat-client.mdx
@@ -0,0 +1,56 @@
+---
+title: useChatClient
+meta_description: "API reference for the useChatClient hook in the Ably Chat React SDK."
+meta_keywords: "Ably Chat SDK, React, useChatClient, hooks, chat client, clientId"
+---
+
+The `useChatClient` hook provides access to the `ChatClient` instance supplied by the [`ChatClientProvider`](/docs/chat/api/react/providers#chatClientProvider). It automatically monitors the `clientId` and refreshes when connection state changes.
+
+
+```react
+import { useChatClient } from '@ably/chat/react';
+
+const MyComponent = () => {
+ const { clientId } = useChatClient();
+ return
Connected as: {clientId}
;
+};
+```
+
+
+This hook must be used within a [`ChatClientProvider`](/docs/chat/api/react/providers#chatClientProvider).
+
+## Returns
+
+The `useChatClient` hook returns an object with the following properties:
+
+
+
+| Property | Description | Type |
+| --- | --- | --- |
+| clientId | The current client identifier. Available immediately when using an Ably API key, but unavailable until a successful server connection when using token authentication. Monitor the connection status to determine connection readiness. | String or Undefined |
+
+
+ );
+}
+```
+
diff --git a/src/pages/docs/chat/api/react/use-chat-connection.mdx b/src/pages/docs/chat/api/react/use-chat-connection.mdx
new file mode 100644
index 0000000000..921504269e
--- /dev/null
+++ b/src/pages/docs/chat/api/react/use-chat-connection.mdx
@@ -0,0 +1,108 @@
+---
+title: useChatConnection
+meta_description: "API reference for the useChatConnection hook in the Ably Chat React SDK."
+meta_keywords: "Ably Chat SDK, React, useChatConnection, hooks, connection status, ConnectionStatus"
+---
+
+The `useChatConnection` hook provides the current connection status and error state between the client and Ably. It supports listener callbacks for status changes and automatically cleans up listeners on component unmount.
+
+
+```react
+import { useChatConnection } from '@ably/chat/react';
+
+const MyComponent = () => {
+ const { currentStatus, error } = useChatConnection();
+ return
Connection: {currentStatus}
;
+};
+```
+
+
+This hook must be used within a [`ChatClientProvider`](/docs/chat/api/react/providers#chatClientProvider).
+
+## Parameters
+
+The `useChatConnection` hook accepts an optional configuration object:
+
+
+
+| Parameter | Required | Description | Type |
+| --- | --- | --- | --- |
+| onStatusChange | Optional | A callback invoked whenever the connection status changes. The listener is removed when the component unmounts. | [ConnectionStatusChange](#connectionStatusChange) |
+
+
+
+## Returns
+
+The `useChatConnection` hook returns an object with the following properties:
+
+
+
+| Property | Description | Type |
+| --- | --- | --- |
+| currentStatus | The current status of the connection, kept up to date by the hook. | [ConnectionStatus](#connectionStatus) |
+| error | An error that provides a reason why the connection has entered the new status, if applicable. Kept up to date by the hook. | [ErrorInfo](/docs/chat/api/react/providers#errorInfo) or Undefined |
+
+
+
+## ConnectionStatus
+
+The status of the connection to Ably.
+
+
+
+| Status | Description |
+| --- | --- |
+| Initialized | A temporary state for when the library is first initialized. The value is `initialized`. |
+| Connecting | The library is currently connecting to Ably. The value is `connecting`. |
+| Connected | A connection exists and is active. The value is `connected`. |
+| Disconnected | The library is currently disconnected from Ably, but will attempt to reconnect. The value is `disconnected`. |
+| Suspended | The library is in an extended state of disconnection, but will attempt to reconnect. The value is `suspended`. |
+| Failed | The library is currently disconnected from Ably and will not attempt to reconnect. The value is `failed`. |
+| Closing | An explicit request by the developer to close the connection has been sent to the Ably service. The value is `closing`. |
+| Closed | The connection has been explicitly closed by the client. No reconnection attempts are made automatically. The value is `closed`. |
+
+
+
+## ConnectionStatusChange
+
+Describes a change in connection status.
+
+
+
+| Property | Description | Type |
+| --- | --- | --- |
+| current | The new connection status. | [ConnectionStatus](#connectionStatus) |
+| previous | The previous connection status. | [ConnectionStatus](#connectionStatus) |
+| error | An error that provides a reason why the connection has entered the new status, if applicable. | [ErrorInfo](/docs/chat/api/react/providers#errorInfo) or Undefined |
+| retryIn | The time in milliseconds that the client will wait before attempting to reconnect, if applicable. | Number or Undefined |
+
+
|
+| reactionsListener | Optional | A callback invoked when reaction summaries change for messages in the room. |
|
+| rawReactionsListener | Optional | A callback invoked for individual reaction events on messages in the room. |
|
+| onDiscontinuity | Optional | A callback to detect and respond to discontinuities in the message stream. | [DiscontinuityListener](/docs/chat/api/react/providers#discontinuityListener) |
+| onRoomStatusChange | Optional | A callback invoked when the room status changes. Removed when the component unmounts. | [RoomStatusChange](/docs/chat/api/react/use-room#roomStatusChange) |
+| onConnectionStatusChange | Optional | A callback invoked when the connection status changes. Removed when the component unmounts. | [ConnectionStatusChange](/docs/chat/api/react/use-chat-connection#connectionStatusChange) |
+
+
+
+
+
+| Parameter | Description | Type |
+| --- | --- | --- |
+| event | The message event that was received. |
|
+
+
+
+
+
+| Property | Description | Type |
+| --- | --- | --- |
+| type | The type of the message event. |
|
+| message | The message that was received. | [Message](#Message) |
+
+
+
+
+
+| Value | Description |
+| --- | --- |
+| Created | A new chat message was received. The value is `message.created`. |
+| Updated | A chat message was updated. The value is `message.updated`. |
+| Deleted | A chat message was deleted. The value is `message.deleted`. |
+
+
+
+| Property | Description | Type |
+| --- | --- | --- |
+| type | The event type. The value is `reaction.summary`. | String |
+| messageSerial | The serial of the message. | String |
+| reactions | The aggregated reaction counts. |
|
+
+
+
+
+
+| Property | Description | Type |
+| --- | --- | --- |
+| unique | Reactions counted with the "unique" strategy (one per client per message). Maps reaction name to summary. |
|
+| distinct | Reactions counted with the "distinct" strategy (one of each type per client). Maps reaction name to summary. |
|
+| multiple | Reactions counted with the "multiple" strategy (unlimited per client). Maps reaction name to summary. |
|
+
+
+
+
+
+| Property | Description | Type |
+| --- | --- | --- |
+| total | The total number of clients who have reacted with this name. | Number |
+| clientIds | A list of the client IDs of all clients who have reacted with this name. | String[] |
+
+
+
+
+
+| Property | Description | Type |
+| --- | --- | --- |
+| total | The total count of reactions with this name across all clients. | Number |
+| clientIds | A map of client ID to the count each client has contributed. | `Record` |
+| totalUnidentified | The total count from unidentified clients not included in `clientIds`. | Number |
+
+
+
+| Property | Description | Type |
+| --- | --- | --- |
+| type | The event type. The value is `reaction.create` or `reaction.delete`. | MessageReactionRawEventType |
+| timestamp | When the event occurred. | Date |
+| reaction | The reaction details. |
|
+
+
+
+
+
+| Property | Required | Description | Type |
+| --- | --- | --- | --- |
+| messageSerial | Required | The serial of the message. | String |
+| type | Required | The counting strategy. |
|
+| name | Required | The reaction identifier. | String |
+| count | Optional | The count for Multiple type reactions. | Number |
+| clientId | Required | The client ID who sent the reaction. | String |
+| userClaim | Optional | The user claim attached to this reaction by the server. Only present if the user's [JWT](/docs/auth/token#jwt) contained a claim for the room. | String or Undefined |
+
+
+
+
+
+| Value | Description |
+| --- | --- |
+| Unique | One reaction per client per message. A second reaction replaces the first. Similar to iMessage, Facebook Messenger, or WhatsApp. The value is `unique`. |
+| Distinct | One reaction of each type per client per message. Multiple different reactions allowed. Similar to Slack. The value is `distinct`. |
+| Multiple | Unlimited reactions including repeats. Includes a count for batch reactions. Similar to Medium claps. The value is `multiple`. |
+
+
+
+## Returns
+
+The `useMessages` hook returns an object with the following properties:
+
+
+
+| Property | Description | Type |
+| --- | --- | --- |
+| sendMessage | Sends a message to the chat room. | [sendMessage()](#send) |
+| getMessage | Retrieves a single message by its serial. | [getMessage()](#get) |
+| updateMessage | Updates a message's content. | [updateMessage()](#update) |
+| deleteMessage | Soft-deletes a message. | [deleteMessage()](#delete) |
+| history | Retrieves historical messages with pagination. | [history()](#history) |
+| historyBeforeSubscribe | Retrieves messages sent before the subscription was established. Only available when a `listener` is provided. | [historyBeforeSubscribe()](#historyBeforeSubscribe) |
+| sendReaction | Sends a reaction to a message. | [sendReaction()](#send-reaction) |
+| deleteReaction | Removes a reaction from a message. | [deleteReaction()](#delete-reaction) |
+| roomStatus | The current status of the room, kept up to date by the hook. | [RoomStatus](/docs/chat/api/react/use-room#roomStatus) |
+| roomError | An error object if the room is in an errored state. | [ErrorInfo](/docs/chat/api/react/providers#errorInfo) or Undefined |
+| connectionStatus | The current connection status, kept up to date by the hook. | [ConnectionStatus](/docs/chat/api/react/use-chat-connection#connectionStatus) |
+| connectionError | An error object if there is a connection error. | [ErrorInfo](/docs/chat/api/react/providers#errorInfo) or Undefined |
+
+
+
+## Send a message
+
+{`sendMessage(params: SendMessageParams): Promise`}
+
+Send a message to the chat room. The message will be delivered to all subscribers in realtime.
+
+This method uses the Ably Chat REST API and does not require the room to be attached.
+
+### Parameters
+
+
+
+| Parameter | Required | Description | Type |
+| --- | --- | --- | --- |
+| params | Required | Message parameters containing the text and optional metadata/headers. |
|
+
+
+
+
+
+| Property | Required | Description | Type |
+| --- | --- | --- | --- |
+| text | Required | The text content of the message. | String |
+| metadata | Optional | Extra information attached to the message for features like animations or linking to external resources. |
|
+| headers | Optional | Additional information in Ably message extras, usable for features like livestream timestamping or message flagging. |
|
+
+
+
+
+
+| Property | Description | Type |
+| --- | --- | --- |
+| | Key-value pairs that can be attached to a message for features like animations, styling hints, or links to external resources. Keys must be non-empty strings. Values can be any JSON-serializable type. Always present on a message, defaults to an empty object if not provided. | `Record` |
+
+
+
+
+
+| Property | Description | Type |
+| --- | --- | --- |
+| | Key-value pairs stored in Ably message extras, accessible to integrations such as webhooks, queues, or serverless functions. Keys must be non-empty strings. Always present on a message, defaults to an empty object if none provided. | `Record` |
+
+
+
+### Returns
+
+`Promise`
+
+Returns a promise. The promise is fulfilled with the sent [Message](#Message) object, or rejected with an [`ErrorInfo`](/docs/chat/api/react/providers#errorInfo) object.
+
+## Get a message
+
+{`getMessage(serial: string): Promise`}
+
+Get a specific message by its unique serial identifier.
+
+This method uses the Ably Chat REST API and does not require the room to be attached.
+
+### Parameters
+
+
+
+| Parameter | Required | Description | Type |
+| --- | --- | --- | --- |
+| serial | Required | The unique serial identifier of the message to retrieve. | String |
+
+
+
+### Returns
+
+`Promise`
+
+Returns a promise. The promise is fulfilled with the [Message](#Message) object matching the given serial, or rejected with an [`ErrorInfo`](/docs/chat/api/react/providers#errorInfo) object.
+
+## Update a message
+
+{`updateMessage(serial: string, params: UpdateMessageParams, details?: OperationDetails): Promise`}
+
+Update a message in the chat room. This method modifies an existing message's content, metadata, or headers. The update creates a new version of the message while preserving the original serial identifier. Subscribers will receive an update event in realtime.
+
+This method uses the Ably Chat REST API and does not require the room to be attached.
+
+### Parameters
+
+
+
+| Parameter | Required | Description | Type |
+| --- | --- | --- | --- |
+| serial | Required | The unique identifier of the message to update. | String |
+| params | Required | The new message content and properties. |
|
+| details | Optional | Details to record about the update action. |
|
+
+
+
+
+
+| Property | Required | Description | Type |
+| --- | --- | --- | --- |
+| text | Required | The new text content of the message. | String |
+| metadata | Optional | New metadata for the message. |
|
+| headers | Optional | New headers for the message. |
|
+
+
+
+
+
+| Property | Required | Description | Type |
+| --- | --- | --- | --- |
+| description | Optional | A human-readable description of why the operation was performed. | String |
+| metadata | Optional | Additional metadata about the operation. |
|
+
+
+
+
+
+| Property | Description | Type |
+| --- | --- | --- |
+| | Metadata supplied to a message update or deletion request. Do not use metadata for authoritative information. There is no server-side validation. When reading the metadata, treat it like user input. | `Record` |
+
+
+
+### Returns
+
+`Promise`
+
+Returns a promise. The promise is fulfilled with the updated [Message](#Message) object, or rejected with an [`ErrorInfo`](/docs/chat/api/react/providers#errorInfo) object. The returned message will have its `action` property set to `updated`.
+
+## Delete a message
+
+{`deleteMessage(serial: string, details?: OperationDetails): Promise`}
+
+Delete a message in the chat room. This method performs a "soft delete" on a message, marking it as deleted rather than permanently removing it. The deleted message will still be visible in message history but will be flagged as deleted. Subscribers will receive a deletion event in realtime.
+
+This method uses the Ably Chat REST API and does not require the room to be attached.
+
+### Parameters
+
+
+
+| Parameter | Required | Description | Type |
+| --- | --- | --- | --- |
+| serial | Required | The unique identifier of the message to delete. | String |
+| details | Optional | Details to record about the delete action. |
|
+
+
+
+### Returns
+
+`Promise`
+
+Returns a promise. The promise is fulfilled with the deleted [Message](#Message) object, or rejected with an [`ErrorInfo`](/docs/chat/api/react/providers#errorInfo) object. The returned message will have its `action` property set to `deleted`.
+
+## Get message history
+
+{`history(params: HistoryParams): Promise>`}
+
+Get messages that have been previously sent to the chat room. This method retrieves historical messages based on the provided query options, allowing you to paginate through message history, filter by time ranges, and control the order of results.
+
+This method uses the Ably Chat REST API and does not require the room to be attached.
+
+### Parameters
+
+
+
+| Parameter | Required | Description | Type |
+| --- | --- | --- | --- |
+| params | Required | Query parameters to filter and control message retrieval. |
|
+
+
+
+
+
+| Property | Required | Description | Type |
+| --- | --- | --- | --- |
+| limit | Optional | Maximum number of messages to retrieve. Default: `100`. | Number |
+| orderBy | Optional | Order in which to return results: `oldestFirst` or `newestFirst`. Default: `newestFirst`. |
|
+| start | Optional | Start of the time window to query, as a Unix timestamp in milliseconds. | Number |
+| end | Optional | End of the time window to query, as a Unix timestamp in milliseconds. | Number |
+
+
+
+
+
+| Value | Description |
+| --- | --- |
+| OldestFirst | Return results starting with the oldest messages. The value is `oldestFirst`. |
+| NewestFirst | Return results starting with the newest messages. The value is `newestFirst`. |
+
+
+
+### Returns
+
+`Promise>`
+
+Returns a promise. The promise is fulfilled with a [`PaginatedResult`](#PaginatedResult) containing an array of [Message](#Message) objects, or rejected with an [`ErrorInfo`](/docs/chat/api/react/providers#errorInfo) object.
+
+## Get messages before subscription
+
+{`historyBeforeSubscribe(params?: HistoryBeforeSubscribeParams): Promise>`}
+
+Get messages sent to the room from before the subscription was established. Only available when a `listener` is provided to the hook. Returns `undefined` if no listener was supplied.
+
+### Parameters
+
+
+
+| Parameter | Required | Description | Type |
+| --- | --- | --- | --- |
+| params | Optional | Query parameters to filter message retrieval. Messages are returned in order of most recent to oldest. |
|
+
+
+
+
+
+| Property | Required | Description | Type |
+| --- | --- | --- | --- |
+| limit | Optional | Maximum number of messages to retrieve. Default: `100`. | Number |
+| start | Optional | Start of the time window to query, as a Unix timestamp in milliseconds. | Number |
+| end | Optional | End of the time window to query, as a Unix timestamp in milliseconds. | Number |
+
+
+
+### Returns
+
+`Promise>`
+
+Returns a promise. The promise is fulfilled with a [`PaginatedResult`](#PaginatedResult) containing an array of [Message](#Message) objects, or rejected with an [`ErrorInfo`](/docs/chat/api/react/providers#errorInfo) object.
+
+## Send a reaction
+
+{`sendReaction(serial: string, params: SendMessageReactionParams): Promise`}
+
+Sends a reaction to a specific chat message. The reaction is persisted and contributes to the message's reaction summary.
+
+This method uses the Ably Chat REST API and does not require the room to be attached.
+
+### Parameters
+
+
+
+| Parameter | Required | Description | Type |
+| --- | --- | --- | --- |
+| serial | Required | The serial of the message to react to. | String |
+| params | Required | The reaction parameters. |
|
+
+
+
+
+
+| Property | Required | Description | Type |
+| --- | --- | --- | --- |
+| name | Required | The reaction identifier, typically an emoji. | String |
+| type | Optional | The counting strategy for this reaction. Defaults vary by room configuration. |
|
+| count | Optional | Number of times to count this reaction. Only applies to `Multiple` type. Defaults to `1`. | Number |
+
+
+
+### Returns
+
+`Promise`
+
+Returns a promise. The promise is fulfilled when the reaction has been sent, or rejected with an [`ErrorInfo`](/docs/chat/api/react/providers#errorInfo) object.
+
+## Delete a reaction
+
+{`deleteReaction(serial: string, params?: DeleteMessageReactionParams): Promise`}
+
+Removes a previously sent reaction from a chat message.
+
+### Parameters
+
+
+
+| Parameter | Required | Description | Type |
+| --- | --- | --- | --- |
+| serial | Required | The serial of the message to remove the reaction from. | String |
+| params | Optional | Parameters identifying which reaction to delete. |
|
+
+
+
+
+
+| Property | Required | Description | Type |
+| --- | --- | --- | --- |
+| name | Optional | The reaction identifier to delete. Required except for `Unique` type. | String |
+| type | Optional | The counting strategy of the reaction to delete. |
|
+
+
+
+### Returns
+
+`Promise`
+
+Returns a promise. The promise is fulfilled when the reaction has been deleted, or rejected with an [`ErrorInfo`](/docs/chat/api/react/providers#errorInfo) object.
+
+## Message
+
+The `Message` interface represents a single message in a chat room.
+
+
+
+| Property | Description | Type |
+| --- | --- | --- |
+| serial | The unique identifier of the message. | String |
+| clientId | The client ID of the user who created the message. | String |
+| userClaim | The user claim attached to this message by the server. Only present if the publishing user's [JWT](/docs/auth/token#jwt) contained a claim for the room in which this message was published. | String or Undefined |
+| text | The text content of the message. | String |
+| timestamp | The timestamp at which the message was created. | Date |
+| metadata | Extra information attached to the message for features like animations or linking to external resources. Always set; empty object if no metadata was provided. |
|
+| headers | Additional information in Ably realtime message extras, usable for features like livestream timestamping or message flagging. Always set; empty object if none provided. |
|
+| action | The action type indicating if the message was created, updated, or deleted. |
|
+| version | Information about the current version of this message. |
|
+| reactions | The reactions summary for this message. |
|
+
+
+
+
+
+| Value | Description |
+| --- | --- |
+| MessageCreate | The message was newly created. The value is `message.create`. |
+| MessageUpdate | The message was updated. The value is `message.update`. |
+| MessageDelete | The message was deleted. The value is `message.delete`. |
+
+
+
+
+
+| Property | Required | Description | Type |
+| --- | --- | --- | --- |
+| serial | Required | The unique identifier for this version. | String |
+| timestamp | Required | When this version was created. | Date |
+| clientId | Optional | The client ID of the user who performed an update or deletion. | String or Undefined |
+| description | Optional | A description of why this version was created. | String or Undefined |
+| metadata | Optional | Additional metadata about the operation. |
or Undefined |
+
+
+
+## PaginatedResult
+
+A `PaginatedResult` represents a page of results from a paginated query such as `history()` or `historyBeforeSubscribe()`.
+
+
+
+| Property | Description | Type |
+| --- | --- | --- |
+| items | The current page of results. | [Message](#Message)[] |
+
+
+
+### Check for more pages
+
+hasNext(): boolean
+
+Returns `true` if there are more pages available by calling `next()`.
+
+### Check if last page
+
+isLast(): boolean
+
+Returns `true` if this is the last page of results.
+
+### Get next page
+
+{`next(): Promise | null>`}
+
+Returns a promise. The promise is fulfilled with the next page of results, or `null` if there are no more pages, or rejected with an [`ErrorInfo`](/docs/chat/api/react/providers#errorInfo) object.
+
+### Get first page
+
+{`first(): Promise>`}
+
+Returns a promise. The promise is fulfilled with the first page of results, or rejected with an [`ErrorInfo`](/docs/chat/api/react/providers#errorInfo) object.
+
+### Get current page
+
+{`current(): Promise>`}
+
+Returns a promise. The promise is fulfilled with the current page of results, or rejected with an [`ErrorInfo`](/docs/chat/api/react/providers#errorInfo) object.
+
+## Example
+
+
+```react
+import { ChatMessageEventType, OrderBy, MessageReactionType } from '@ably/chat';
+import { useMessages } from '@ably/chat/react';
+import { useState, useCallback } from 'react';
+
+function ChatMessages() {
+ const [messages, setMessages] = useState([]);
+
+ const { sendMessage, updateMessage, deleteMessage, history, sendReaction } = useMessages({
+ listener: (event) => {
+ setMessages((prev) => {
+ switch (event.type) {
+ case ChatMessageEventType.Created:
+ return [...prev, event.message];
+ case ChatMessageEventType.Updated:
+ case ChatMessageEventType.Deleted:
+ return prev.map((msg) =>
+ msg.serial === event.message.serial ? event.message : msg
+ );
+ default:
+ return prev;
+ }
+ });
+ },
+ reactionsListener: (event) => {
+ setMessages((prev) =>
+ prev.map((msg) =>
+ msg.serial === event.messageSerial
+ ? msg.with(event)
+ : msg
+ )
+ );
+ },
+ });
+
+ const loadHistory = useCallback(async () => {
+ const result = await history({ limit: 50, orderBy: OrderBy.OldestFirst });
+ setMessages(result.items);
+ }, [history]);
+
+ const handleSend = useCallback(async (text) => {
+ await sendMessage({ text });
+ }, [sendMessage]);
+
+ const handleReact = useCallback(async (serial, emoji) => {
+ await sendReaction(serial, { name: emoji, type: MessageReactionType.Distinct });
+ }, [sendReaction]);
+
+ return (
+
+
+ {messages.map((msg) => (
+
+ {msg.clientId}: {msg.text}
+
+
+
+ ))}
+
+
+ );
+}
+```
+
diff --git a/src/pages/docs/chat/api/react/use-occupancy.mdx b/src/pages/docs/chat/api/react/use-occupancy.mdx
new file mode 100644
index 0000000000..41475d8ff3
--- /dev/null
+++ b/src/pages/docs/chat/api/react/use-occupancy.mdx
@@ -0,0 +1,109 @@
+---
+title: useOccupancy
+meta_description: "API reference for the useOccupancy hook in the Ably Chat React SDK."
+meta_keywords: "Ably Chat SDK, React, useOccupancy, hooks, occupancy, connections, presence members, user count"
+---
+
+The `useOccupancy` hook provides realtime room occupancy information, automatically tracking the number of connections and presence members in a room.
+
+
+```react
+import { useOccupancy } from '@ably/chat/react';
+
+const MyComponent = () => {
+ const { connections, presenceMembers } = useOccupancy();
+ return
;
+};
+```
+
+
+This hook must be used within a [`ChatRoomProvider`](/docs/chat/api/react/providers#chatRoomProvider).
+
+## Parameters
+
+The `useOccupancy` hook accepts an optional configuration object:
+
+
+
+| Parameter | Required | Description | Type |
+| --- | --- | --- | --- |
+| listener | Optional | A callback invoked whenever an occupancy event is received. Removed when the component unmounts. |
|
+| onDiscontinuity | Optional | A callback to detect and respond to discontinuities. | [DiscontinuityListener](/docs/chat/api/react/providers#discontinuityListener) |
+| onRoomStatusChange | Optional | A callback invoked when the room status changes. Removed when the component unmounts. | [RoomStatusChange](/docs/chat/api/react/use-room#roomStatusChange) |
+| onConnectionStatusChange | Optional | A callback invoked when the connection status changes. Removed when the component unmounts. | [ConnectionStatusChange](/docs/chat/api/react/use-chat-connection#connectionStatusChange) |
+
+
+
+| Property | Description | Type |
+| --- | --- | --- |
+| type | The type of occupancy event. |
|
+| occupancy | The current occupancy data. |
|
+
+
+
+
+
+| Value | Description |
+| --- | --- |
+| Updated | The room occupancy has been updated. The value is `occupancy.updated`. |
+
+
+
+
+
+| Property | Description | Type |
+| --- | --- | --- |
+| connections | The number of active connections to the room. | Number |
+| presenceMembers | The number of users in the presence set. | Number |
+
+
+
+## Returns
+
+The `useOccupancy` hook returns an object with the following properties:
+
+
+
+| Property | Description | Type |
+| --- | --- | --- |
+| connections | The current number of users connected to the room, kept up to date by the hook. | Number |
+| presenceMembers | The current number of users present in the room, kept up to date by the hook. | Number |
+| roomStatus | The current status of the room, kept up to date by the hook. | [RoomStatus](/docs/chat/api/react/use-room#roomStatus) |
+| roomError | An error object if the room is in an errored state. | [ErrorInfo](/docs/chat/api/react/providers#errorInfo) or Undefined |
+| connectionStatus | The current connection status, kept up to date by the hook. | [ConnectionStatus](/docs/chat/api/react/use-chat-connection#connectionStatus) |
+| connectionError | An error object if there is a connection error. | [ErrorInfo](/docs/chat/api/react/providers#errorInfo) or Undefined |
+
+
+ );
+}
+```
+
diff --git a/src/pages/docs/chat/api/react/use-presence-listener.mdx b/src/pages/docs/chat/api/react/use-presence-listener.mdx
new file mode 100644
index 0000000000..5eb398457c
--- /dev/null
+++ b/src/pages/docs/chat/api/react/use-presence-listener.mdx
@@ -0,0 +1,153 @@
+---
+title: usePresenceListener
+meta_description: "API reference for the usePresenceListener hook in the Ably Chat React SDK."
+meta_keywords: "Ably Chat SDK, React, usePresenceListener, hooks, presence, members, online users, subscribe"
+---
+
+The `usePresenceListener` hook provides live presence information for all users in a room. It automatically subscribes to presence events and maintains an up-to-date roster of presence members. Use [`usePresence`](/docs/chat/api/react/use-presence) to manage the current user's own presence state.
+
+
+```react
+import { usePresenceListener } from '@ably/chat/react';
+
+const MyComponent = () => {
+ const { presenceData } = usePresenceListener();
+
+ return (
+
+ {presenceData.map((member) => (
+
{member.clientId}
+ ))}
+
+ );
+};
+```
+
+
+This hook must be used within a [`ChatRoomProvider`](/docs/chat/api/react/providers#chatRoomProvider).
+
+## Parameters
+
+The `usePresenceListener` hook accepts an optional configuration object:
+
+
+
+| Parameter | Required | Description | Type |
+| --- | --- | --- | --- |
+| listener | Optional | A callback invoked whenever the presence state changes. Removed when the component unmounts. |
|
+| onDiscontinuity | Optional | A callback to detect and respond to discontinuities. | [DiscontinuityListener](/docs/chat/api/react/providers#discontinuityListener) |
+| onRoomStatusChange | Optional | A callback invoked when the room status changes. Removed when the component unmounts. | [RoomStatusChange](/docs/chat/api/react/use-room#roomStatusChange) |
+| onConnectionStatusChange | Optional | A callback invoked when the connection status changes. Removed when the component unmounts. | [ConnectionStatusChange](/docs/chat/api/react/use-chat-connection#connectionStatusChange) |
+
+
+
+| Property | Description | Type |
+| --- | --- | --- |
+| type | The type of presence event. |
|
+| member | The presence member associated with this event. |
|
+
+
+
+
+
+| Value | Description |
+| --- | --- |
+| Enter | A user has entered the presence set. The value is `enter`. |
+| Leave | A user has left the presence set. The value is `leave`. |
+| Update | A user has updated their presence data. The value is `update`. |
+| Present | Indicates a user is present (received during initial sync). The value is `present`. |
+
+
+
+
+
+| Property | Description | Type |
+| --- | --- | --- |
+| clientId | The client ID of the present user. | String |
+| userClaim | The user claim attached to this presence event by the server. Only present if the user's [JWT](/docs/auth/token#jwt) contained a claim for the room. | String or Undefined |
+| connectionId | The connection ID of the present user. | String |
+| data | The presence data associated with the user. |
or Undefined |
+| extras | Additional data included with the presence message. | JsonObject or Undefined |
+| updatedAt | When this presence state was last updated. | Date |
+
+
+
+
+
+| Property | Description | Type |
+| --- | --- | --- |
+| | JSON-serializable data that can be associated with a user's presence in a room. | JsonObject |
+
+
+
+## Returns
+
+The `usePresenceListener` hook returns an object with the following properties:
+
+
+
+| Property | Description | Type |
+| --- | --- | --- |
+| presenceData | The current state of all presence members, updated in realtime. Only emitted while presence is not syncing. |
[] |
+| error | Tracks presence listener errors during asynchronous data fetching. Set when the initial presence data fetch fails or when errors occur after presence events. Clears upon successful new presence event processing. | [ErrorInfo](/docs/chat/api/react/providers#errorInfo) or Undefined |
+| roomStatus | The current status of the room, kept up to date by the hook. | [RoomStatus](/docs/chat/api/react/use-room#roomStatus) |
+| roomError | An error object if the room is in an errored state. | [ErrorInfo](/docs/chat/api/react/providers#errorInfo) or Undefined |
+| connectionStatus | The current connection status, kept up to date by the hook. | [ConnectionStatus](/docs/chat/api/react/use-chat-connection#connectionStatus) |
+| connectionError | An error object if there is a connection error. | [ErrorInfo](/docs/chat/api/react/providers#errorInfo) or Undefined |
+
+
+
+## Example
+
+
+```react
+import { PresenceEventType } from '@ably/chat';
+import { usePresenceListener } from '@ably/chat/react';
+
+function OnlineUsers() {
+ const { presenceData, error } = usePresenceListener({
+ listener: (event) => {
+ switch (event.type) {
+ case PresenceEventType.Enter:
+ console.log(`${event.member.clientId} joined`);
+ break;
+ case PresenceEventType.Leave:
+ console.log(`${event.member.clientId} left`);
+ break;
+ case PresenceEventType.Update:
+ console.log(`${event.member.clientId} updated their status`);
+ break;
+ }
+ },
+ });
+
+ if (error) {
+ return
+ );
+}
+```
+
diff --git a/src/pages/docs/chat/api/react/use-presence.mdx b/src/pages/docs/chat/api/react/use-presence.mdx
new file mode 100644
index 0000000000..1c6922d0dd
--- /dev/null
+++ b/src/pages/docs/chat/api/react/use-presence.mdx
@@ -0,0 +1,172 @@
+---
+title: usePresence
+meta_description: "API reference for the usePresence hook in the Ably Chat React SDK."
+meta_keywords: "Ably Chat SDK, React, usePresence, hooks, presence, enter, leave, update, online users"
+---
+
+The `usePresence` hook manages the current user's presence in a chat room. By default, it automatically enters presence on mount and leaves on unmount. Use [`usePresenceListener`](/docs/chat/api/react/use-presence-listener) to observe the presence state of all users.
+
+
+```react
+import { usePresence } from '@ably/chat/react';
+
+const MyComponent = () => {
+ const { update, myPresenceState } = usePresence();
+
+ return (
+
+
Present: {myPresenceState.present ? 'Yes' : 'No'}
+
+
+ );
+};
+```
+
+
+This hook must be used within a [`ChatRoomProvider`](/docs/chat/api/react/providers#chatRoomProvider).
+
+
+
+## Parameters
+
+The `usePresence` hook accepts an optional configuration object:
+
+
+
+| Parameter | Required | Description | Type |
+| --- | --- | --- | --- |
+| autoEnterLeave | Optional | Whether the hook should automatically enter presence on mount and leave on unmount. If `leave()` is invoked, automatic entry is disabled until `enter` or `update` is called. Default: `true`. | Boolean |
+| initialData | Optional | Data to use when auto-entering the room. Only applies to the initial auto-enter on component mount; subsequent modifications are disregarded. Use `update` or `enter` for post-entry data changes. |
|
+| onDiscontinuity | Optional | A callback to detect and respond to discontinuities. | [DiscontinuityListener](/docs/chat/api/react/providers#discontinuityListener) |
+| onRoomStatusChange | Optional | A callback invoked when the room status changes. Removed when the component unmounts. | [RoomStatusChange](/docs/chat/api/react/use-room#roomStatusChange) |
+| onConnectionStatusChange | Optional | A callback invoked when the connection status changes. Removed when the component unmounts. | [ConnectionStatusChange](/docs/chat/api/react/use-chat-connection#connectionStatusChange) |
+
+
+
+
+
+| Property | Description | Type |
+| --- | --- | --- |
+| | JSON-serializable data that can be associated with a user's presence in a room. | JsonObject |
+
+
+
+## Returns
+
+The `usePresence` hook returns an object with the following properties:
+
+
+
+| Property | Description | Type |
+| --- | --- | --- |
+| enter | Enters the current user into the presence set. | [enter()](#enter) |
+| leave | Removes the current user from the presence set. | [leave()](#leave) |
+| update | Updates the current user's presence data. | [update()](#update) |
+| myPresenceState | The current presence state of the user, including whether they are present and any errors. |
|
+| roomStatus | The current status of the room, kept up to date by the hook. | [RoomStatus](/docs/chat/api/react/use-room#roomStatus) |
+| roomError | An error object if the room is in an errored state. | [ErrorInfo](/docs/chat/api/react/providers#errorInfo) or Undefined |
+| connectionStatus | The current connection status, kept up to date by the hook. | [ConnectionStatus](/docs/chat/api/react/use-chat-connection#connectionStatus) |
+| connectionError | An error object if there is a connection error. | [ErrorInfo](/docs/chat/api/react/providers#errorInfo) or Undefined |
+
+
+
+
+
+| Property | Description | Type |
+| --- | --- | --- |
+| present | Whether the current user is present in the room. | Boolean |
+| error | An error associated with the presence state, if any. | [ErrorInfo](/docs/chat/api/react/providers#errorInfo) or Undefined |
+
+
+
+## Enter presence
+
+{`enter(data?: PresenceData): Promise`}
+
+Enters the current user into the chat room presence set. This notifies other users that you have joined the room.
+
+### Parameters
+
+
+
+| Parameter | Required | Description | Type |
+| --- | --- | --- | --- |
+| data | Optional | JSON-serializable data to associate with the user's presence. |
|
+
+
+
+### Returns
+
+`Promise`
+
+Returns a promise. The promise is fulfilled when the user has successfully entered the presence set, or rejected with an [`ErrorInfo`](/docs/chat/api/react/providers#errorInfo) object.
+
+## Update presence data
+
+{`update(data?: PresenceData): Promise`}
+
+Updates the presence data for the current user in the chat room. Use this to change your status or other presence information without leaving and re-entering. Automatically enters if not already present.
+
+### Parameters
+
+
+
+| Parameter | Required | Description | Type |
+| --- | --- | --- | --- |
+| data | Optional | JSON-serializable data to replace the user's current presence data. |
|
+
+
+
+### Returns
+
+`Promise`
+
+Returns a promise. The promise is fulfilled when the presence data has been updated, or rejected with an [`ErrorInfo`](/docs/chat/api/react/providers#errorInfo) object.
+
+## Leave presence
+
+{`leave(data?: PresenceData): Promise`}
+
+Removes the current user from the chat room presence set. This notifies other users that you have left the room. If `autoEnterLeave` is `true`, calling `leave()` prevents automatic re-entry until `enter` or `update` is called.
+
+### Parameters
+
+
+
+| Parameter | Required | Description | Type |
+| --- | --- | --- | --- |
+| data | Optional | Final presence data to include with the leave event. |
|
+
+
+
+### Returns
+
+`Promise`
+
+Returns a promise. The promise is fulfilled when the user has left the presence set, or rejected with an [`ErrorInfo`](/docs/chat/api/react/providers#errorInfo) object.
+
+## Example
+
+
+```react
+import { usePresence } from '@ably/chat/react';
+
+function PresenceControls() {
+ const { enter, leave, update, myPresenceState } = usePresence({
+ initialData: { status: 'online', nickname: 'Alice' },
+ });
+
+ return (
+
+ );
+}
+```
+
diff --git a/src/pages/docs/chat/api/react/use-room-reactions.mdx b/src/pages/docs/chat/api/react/use-room-reactions.mdx
new file mode 100644
index 0000000000..5b17495479
--- /dev/null
+++ b/src/pages/docs/chat/api/react/use-room-reactions.mdx
@@ -0,0 +1,169 @@
+---
+title: useRoomReactions
+meta_description: "API reference for the useRoomReactions hook in the Ably Chat React SDK."
+meta_keywords: "Ably Chat SDK, React, useRoomReactions, hooks, room reactions, ephemeral reactions, emoji"
+---
+
+The `useRoomReactions` hook enables sending and subscribing to ephemeral room-level reactions. Room reactions are commonly used for live interactions like floating emojis, applause, or other realtime audience feedback. Unlike message reactions, room reactions are not persisted.
+
+
+```react
+import { useRoomReactions } from '@ably/chat/react';
+
+const MyComponent = () => {
+ const { sendRoomReaction } = useRoomReactions({
+ listener: (event) => {
+ console.log(`${event.reaction.clientId} reacted with ${event.reaction.name}`);
+ },
+ });
+
+ return ;
+};
+```
+
+
+This hook must be used within a [`ChatRoomProvider`](/docs/chat/api/react/providers#chatRoomProvider).
+
+## Parameters
+
+The `useRoomReactions` hook accepts an optional configuration object:
+
+
+
+| Parameter | Required | Description | Type |
+| --- | --- | --- | --- |
+| listener | Optional | A callback invoked whenever a room reaction is received. Removed when the component unmounts. |
|
+| onDiscontinuity | Optional | A callback to detect and respond to discontinuities. | [DiscontinuityListener](/docs/chat/api/react/providers#discontinuityListener) |
+| onRoomStatusChange | Optional | A callback invoked when the room status changes. Removed when the component unmounts. | [RoomStatusChange](/docs/chat/api/react/use-room#roomStatusChange) |
+| onConnectionStatusChange | Optional | A callback invoked when the connection status changes. Removed when the component unmounts. | [ConnectionStatusChange](/docs/chat/api/react/use-chat-connection#connectionStatusChange) |
+
+
+
+| Property | Description | Type |
+| --- | --- | --- |
+| type | The type of the event. Always `Reaction`. |
|
+| reaction | The reaction that was received. |
|
+
+
+
+
+
+| Value | Description |
+| --- | --- |
+| Reaction | A room-level reaction was received. The value is `reaction`. |
+
+
+
+
+
+| Property | Description | Type |
+| --- | --- | --- |
+| name | The name of the reaction (for example, an emoji). | String |
+| clientId | The client ID of the user who sent the reaction. | String |
+| userClaim | The user claim attached to this reaction by the server. Only present if the user's [JWT](/docs/auth/token#jwt) contained a claim for the room. | String or Undefined |
+| metadata | Additional metadata included with the reaction. Empty object if none provided. | JsonObject |
+| headers | Additional information from Ably message extras. Empty object if none provided. | Headers |
+| createdAt | When the reaction was sent. | Date |
+| isSelf | Whether the reaction was sent by the current client. | Boolean |
+
+
+
+## Returns
+
+The `useRoomReactions` hook returns an object with the following properties:
+
+
+
+| Property | Description | Type |
+| --- | --- | --- |
+| sendRoomReaction | Sends a room-level reaction. | [sendRoomReaction()](#send) |
+| roomStatus | The current status of the room, kept up to date by the hook. | [RoomStatus](/docs/chat/api/react/use-room#roomStatus) |
+| roomError | An error object if the room is in an errored state. | [ErrorInfo](/docs/chat/api/react/providers#errorInfo) or Undefined |
+| connectionStatus | The current connection status, kept up to date by the hook. | [ConnectionStatus](/docs/chat/api/react/use-chat-connection#connectionStatus) |
+| connectionError | An error object if there is a connection error. | [ErrorInfo](/docs/chat/api/react/providers#errorInfo) or Undefined |
+
+
+
+## Send a room reaction
+
+{`sendRoomReaction(params: SendReactionParams): Promise`}
+
+Sends a room-level reaction. Room reactions are ephemeral events that are not associated with specific messages.
+
+### Parameters
+
+
+
+| Property | Required | Description | Type |
+| --- | --- | --- | --- |
+| name | Required | The name of the reaction, typically an emoji or identifier. | String |
+| metadata | Optional | Additional metadata to include with the reaction. | JsonObject |
+| headers | Optional | Additional information in Ably message extras, usable for features like referencing external resources. | Headers |
+
+
+
+### Returns
+
+`Promise`
+
+Returns a promise. The promise is fulfilled when the reaction has been sent, or rejected with an [`ErrorInfo`](/docs/chat/api/react/providers#errorInfo) object.
+
+## Example
+
+
+```react
+import { useRoomReactions } from '@ably/chat/react';
+import { useState, useCallback } from 'react';
+
+function ReactionBar() {
+ const [recentReactions, setRecentReactions] = useState([]);
+
+ const { sendRoomReaction } = useRoomReactions({
+ listener: (event) => {
+ const { reaction } = event;
+ setRecentReactions((prev) => [
+ ...prev.slice(-9),
+ { name: reaction.name, clientId: reaction.clientId, isSelf: reaction.isSelf },
+ ]);
+ },
+ });
+
+ const emojis = ['👍', '❤️', '😂', '🎉', '👏'];
+
+ return (
+
+ );
+}
+```
+
diff --git a/src/pages/docs/chat/api/react/use-room.mdx b/src/pages/docs/chat/api/react/use-room.mdx
new file mode 100644
index 0000000000..4a095f97d6
--- /dev/null
+++ b/src/pages/docs/chat/api/react/use-room.mdx
@@ -0,0 +1,141 @@
+---
+title: useRoom
+meta_description: "API reference for the useRoom hook in the Ably Chat React SDK."
+meta_keywords: "Ably Chat SDK, React, useRoom, hooks, room, attach, detach, RoomStatus"
+---
+
+The `useRoom` hook provides access to room information and basic room operations such as manually attaching and detaching.
+
+
+```react
+import { useRoom } from '@ably/chat/react';
+
+const MyComponent = () => {
+ const { roomName, roomStatus } = useRoom();
+ return
Room: {roomName} ({roomStatus})
;
+};
+```
+
+
+This hook must be used within a [`ChatRoomProvider`](/docs/chat/api/react/providers#chatRoomProvider).
+
+
+
+## Parameters
+
+The `useRoom` hook accepts an optional configuration object:
+
+
+
+| Parameter | Required | Description | Type |
+| --- | --- | --- | --- |
+| onStatusChange | Optional | A callback invoked when the room status changes. Removed when the component unmounts. | [RoomStatusChange](#roomStatusChange) |
+| onConnectionStatusChange | Optional | A callback invoked when the connection status changes. Removed when the component unmounts. | [ConnectionStatusChange](/docs/chat/api/react/use-chat-connection#connectionStatusChange) |
+
+
+
+## Returns
+
+The `useRoom` hook returns an object with the following properties:
+
+
+
+| Property | Description | Type |
+| --- | --- | --- |
+| roomName | The unique identifier of the room. | String |
+| roomStatus | The current status of the room, kept up to date by the hook. | [RoomStatus](#roomStatus) |
+| roomError | An error object if the room is in an errored state. | [ErrorInfo](/docs/chat/api/react/providers#errorInfo) or Undefined |
+| connectionStatus | The current connection status, kept up to date by the hook. | [ConnectionStatus](/docs/chat/api/react/use-chat-connection#connectionStatus) |
+| connectionError | An error object if there is a connection error. | [ErrorInfo](/docs/chat/api/react/providers#errorInfo) or Undefined |
+| attach | Manually attach to the room. | [attach()](#attach) |
+| detach | Manually detach from the room. | [detach()](#detach) |
+
+
+
+## Attach to a room
+
+{`attach(): Promise`}
+
+Attach to the room to start receiving messages and events. The `ChatRoomProvider` handles this automatically; this method is only needed for manual lifecycle control.
+
+### Returns
+
+`Promise`
+
+Returns a promise. The promise is fulfilled when the room is attached, or rejected with an [`ErrorInfo`](/docs/chat/api/react/providers#errorInfo) object.
+
+## Detach from a room
+
+{`detach(): Promise`}
+
+Detach from the room to stop receiving messages and events. Existing subscriptions are preserved but will not receive events until the room is re-attached. The `ChatRoomProvider` handles this automatically; this method is only needed for manual lifecycle control.
+
+### Returns
+
+`Promise`
+
+Returns a promise. The promise is fulfilled when the room is detached, or rejected with an [`ErrorInfo`](/docs/chat/api/react/providers#errorInfo) object.
+
+## RoomStatus
+
+The status of a chat room.
+
+
+
+| Status | Description |
+| --- | --- |
+| Initializing | The library is currently initializing the room. This is a temporary state used in React prior to the room being resolved. The value is `initializing`. |
+| Initialized | The room has been initialized, but no attach has been attempted yet. The value is `initialized`. |
+| Attaching | An attach has been initiated by sending a request to Ably. This is a transient status and will be followed by a transition to `Attached`, `Suspended`, or `Failed`. The value is `attaching`. |
+| Attached | The room is attached and actively receiving events. In this status, clients can publish and subscribe to messages, and enter the presence set. The value is `attached`. |
+| Detaching | A detach has been initiated on the attached room by sending a request to Ably. This is a transient status and will be followed by a transition to `Detached` or `Failed`. The value is `detaching`. |
+| Detached | The room has been detached by the client and is no longer receiving events. The value is `detached`. |
+| Suspended | The room, having previously been attached, has lost continuity. This typically occurs when the client is disconnected from Ably for more than two minutes. The client will automatically attempt to reattach when connectivity is restored. The value is `suspended`. |
+| Failed | An indefinite failure condition. This status is entered if an error is received from Ably, such as an attempt to attach without the necessary access rights. The value is `failed`. |
+| Releasing | The room is being released and its resources are being cleaned up. Attempting to use a room in this state may result in undefined behavior. The value is `releasing`. |
+| Released | The room has been released and is no longer usable. A new room instance must be obtained to continue using the room. The value is `released`. |
+
+
+
+## RoomStatusChange
+
+Describes a change in room status.
+
+
+
+| Property | Description | Type |
+| --- | --- | --- |
+| current | The new status of the room. | [RoomStatus](#roomStatus) |
+| previous | The previous status of the room. | [RoomStatus](#roomStatus) |
+| error | An error that provides a reason why the room has entered the new status, if applicable. | [ErrorInfo](/docs/chat/api/react/providers#errorInfo) or Undefined |
+
+
+ );
+};
+```
+
+
+This hook must be used within a [`ChatRoomProvider`](/docs/chat/api/react/providers#chatRoomProvider).
+
+## Parameters
+
+The `useTyping` hook accepts an optional configuration object:
+
+
+
+| Parameter | Required | Description | Type |
+| --- | --- | --- | --- |
+| listener | Optional | A callback invoked whenever a typing event occurs. Removed when the component unmounts. |
|
+| onDiscontinuity | Optional | A callback to detect and respond to discontinuities. | [DiscontinuityListener](/docs/chat/api/react/providers#discontinuityListener) |
+| onRoomStatusChange | Optional | A callback invoked when the room status changes. Removed when the component unmounts. | [RoomStatusChange](/docs/chat/api/react/use-room#roomStatusChange) |
+| onConnectionStatusChange | Optional | A callback invoked when the connection status changes. Removed when the component unmounts. | [ConnectionStatusChange](/docs/chat/api/react/use-chat-connection#connectionStatusChange) |
+
+
+
+| Property | Description | Type |
+| --- | --- | --- |
+| type | The type of the event. Always `SetChanged`. |
|
+| currentTypers | The set of users currently typing, with associated metadata such as user claims. |
[] |
+| change | Information about the specific change that triggered this event. |
|
+
+
+
+
+
+| Value | Description |
+| --- | --- |
+| SetChanged | The set of currently typing users has changed. The value is `typing.set.changed`. |
+
+
+
+
+
+| Property | Description | Type |
+| --- | --- | --- |
+| clientId | The client ID of the typing user. | String |
+| userClaim | The user claim attached to this typing event by the server. Only present if the user's [JWT](/docs/auth/token#jwt) contained a claim for the room. | String or Undefined |
+
+
+
+
+
+| Property | Description | Type |
+| --- | --- | --- |
+| clientId | The client ID whose typing state changed. | String |
+| type | Whether the user started or stopped typing. |
|
+| userClaim | The user claim attached to this typing event by the server. Only present if the user's [JWT](/docs/auth/token#jwt) contained a claim for the room. | String or Undefined |
+
+
+
+
+
+| Value | Description |
+| --- | --- |
+| Started | A user has started typing. The value is `typing.started`. |
+| Stopped | A user has stopped typing. The value is `typing.stopped`. |
+
+
+
+## Returns
+
+The `useTyping` hook returns an object with the following properties:
+
+
+
+| Property | Description | Type |
+| --- | --- | --- |
+| currentTypers | The set of users currently typing in the room, with associated metadata. Updated automatically from room events. |
[] |
+| keystroke | Sends a typing-started notification. | [keystroke()](#keystroke) |
+| stop | Sends a typing-stopped notification. | [stop()](#stop) |
+| roomStatus | The current status of the room, kept up to date by the hook. | [RoomStatus](/docs/chat/api/react/use-room#roomStatus) |
+| roomError | An error object if the room is in an errored state. | [ErrorInfo](/docs/chat/api/react/providers#errorInfo) or Undefined |
+| connectionStatus | The current connection status, kept up to date by the hook. | [ConnectionStatus](/docs/chat/api/react/use-chat-connection#connectionStatus) |
+| connectionError | An error object if there is a connection error. | [ErrorInfo](/docs/chat/api/react/providers#errorInfo) or Undefined |
+
+
+
+## Start typing
+
+{`keystroke(): Promise`}
+
+Sends a typing started event to notify other users that the current user is typing.
+
+Events are throttled according to the `heartbeatThrottleMs` room option to prevent excessive network traffic. If called within the throttle interval, the operation becomes a no-op.
+
+### Returns
+
+`Promise`
+
+Returns a promise. The promise is fulfilled when the typing event has been sent, or rejected with an [`ErrorInfo`](/docs/chat/api/react/providers#errorInfo) object.
+
+## Stop typing
+
+{`stop(): Promise`}
+
+Sends a typing stopped event to notify other users that the current user has stopped typing.
+
+If the user is not currently typing, this operation is a no-op.
+
+### Returns
+
+`Promise`
+
+Returns a promise. The promise is fulfilled when the typing stopped event has been sent, or rejected with an [`ErrorInfo`](/docs/chat/api/react/providers#errorInfo) object.
+
+## Example
+
+
+```react
+import { useTyping } from '@ably/chat/react';
+import { useState, useCallback } from 'react';
+
+function MessageInput({ onSend }) {
+ const [text, setText] = useState('');
+ const { keystroke, stop, currentTypers } = useTyping({
+ listener: (event) => {
+ const { change } = event;
+ if (change.type === 'typing.started') {
+ console.log(`${change.clientId} started typing`);
+ }
+ },
+ });
+
+ const handleInput = useCallback((e) => {
+ setText(e.target.value);
+ if (e.target.value.length > 0) {
+ keystroke();
+ } else {
+ stop();
+ }
+ }, [keystroke, stop]);
+
+ const handleSubmit = useCallback(async () => {
+ await onSend(text);
+ setText('');
+ await stop();
+ }, [text, onSend, stop]);
+
+ return (
+
+ {currentTypers.length > 0 && (
+
+ {currentTypers.length === 1
+ ? `${currentTypers[0].clientId} is typing...`
+ : `${currentTypers.map(t => t.clientId).join(', ')} are typing...`}
+