# useTransportStatus The `useTransportStatus` hook reports whether the transport has seen a discontinuity, and the latest error it reported that has no caller to reject. A discontinuity is a channel state change after which messages may have been missed. #### Javascript ``` import { useTransportStatus } from '@ably/ai-transport/react'; function Status() { const { discontinuity, error } = useTransportStatus(); if (error) return

Something went wrong: {error.message}

; if (discontinuity) return

Reconnected. Catching up.

; return null; } ```
This hook must be used within a [`TransportProvider`](https://ably.com/docs/ai-transport/api/react/transport-provider.md). To read whether the channel is attached, use `useChannelStateListener` from `ably/react`, which works inside the provider. `discontinuity` stays `true` once it is set. To recover after every discontinuity, listen with `transport.on('discontinuity')` and subscribe again from the serial of the last message you received, as the [example](#example) shows. ## Parameters | Parameter | Required | Description | Type | | --- | --- | --- | --- | | channelName | optional | The channel name of the provider to read. Omit it to read the nearest provider. | String |
The hook throws an [`ErrorInfo`](https://ably.com/docs/ai-transport/api/errors.md#errorinfo) with `InvalidArgument` when no matching `TransportProvider` encloses the component. ## Returns | Property | Description | Type | | --- | --- | --- | | discontinuity | `true` once the transport has reported a discontinuity. It resets when the provider creates a new transport. | Boolean | | error | The latest error the transport reported with no caller to reject, such as a failed attach or a codec that threw while decoding, or `undefined`. | [`ErrorInfo`](https://ably.com/docs/ai-transport/api/errors.md#errorinfo) or `undefined` |
## Example A component replays the conversation from the stored serial when it loads. After each discontinuity, it subscribes again from the serial of the last message it received. ### Javascript ``` import { useEffect, useRef } from 'react'; import { fromSerial } from '@ably/ai-transport'; import { useTransport, useTransportStatus } from '@ably/ai-transport/react'; function Conversation({ storedSerial, render }) { const { transport } = useTransport(); const { discontinuity } = useTransportStatus(); const lastSeen = useRef(storedSerial); useEffect(() => { if (!transport) return; const apply = (delivery) => { render(delivery); if (delivery.message.serial > lastSeen.current) lastSeen.current = delivery.message.serial; }; const subscribeFrom = (serial) => transport.subscribe(apply, serial ? { history: { replay: fromSerial(serial) } } : undefined); let unsubscribe = subscribeFrom(lastSeen.current); const off = transport.on('discontinuity', () => { unsubscribe(); unsubscribe = subscribeFrom(lastSeen.current); }); return () => { off(); unsubscribe(); }; }, [transport, render]); return discontinuity ?

Reconnected.

: null; } ```
## Related Topics - [TransportProvider](https://ably.com/docs/ai-transport/api/react/transport-provider.md): API reference for the AI Transport TransportProvider: create a transport for a channel and make it available to React components. - [useTransport](https://ably.com/docs/ai-transport/api/react/use-transport.md): API reference for the AI Transport useTransport hook: read the transport from the nearest or a named TransportProvider. - [useDeliveries](https://ably.com/docs/ai-transport/api/react/use-deliveries.md): API reference for the AI Transport useDeliveries hook: receive every delivery on the transport's channel while a component is mounted. - [useHistory](https://ably.com/docs/ai-transport/api/react/use-history.md): API reference for the AI Transport useHistory hook: read the channel's history one page at a time, oldest first. ## Documentation Index To discover additional Ably documentation: 1. Fetch [llms.txt](https://ably.com/llms.txt) for the canonical list of available pages. 2. Identify relevant URLs from that index. 3. Fetch target pages as needed. Avoid using assumed or outdated documentation paths.