# useHistory
The `useHistory` hook reads the channel's history backwards from the point where the channel attached, one page at a time, and keeps the deliveries it has read in one list, oldest first. It reads the first page when the transport is available, and `loadMore` reads the next older page.
#### Javascript
```
import { useHistory } from '@ably/ai-transport/react';
function Earlier() {
const { items, hasNext, loading, loadMore } = useHistory({ limit: 50 });
return (
<>
{hasNext && }
This hook must be used within a [`TransportProvider`](https://ably.com/docs/ai-transport/api/react/transport-provider.md).
Reading history attaches the channel. The list starts again when the provider creates a new transport.
## Parameters
### Javascript
```
import { useHistory } from '@ably/ai-transport/react';
function ConversationHistory() {
const { items, hasNext, loading, error, loadMore } = useHistory({ limit: 30 });
const onScroll = (e) => {
if (e.currentTarget.scrollTop === 0 && hasNext && !loading) void loadMore();
};
if (error) return Could not load history: {error.message}
;
return (
{items.map(({ message, event }, i) => (event ?
: 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.
- [useTransportStatus](https://ably.com/docs/ai-transport/api/react/use-transport-status.md): API reference for the AI Transport useTransportStatus hook: observe the transport's discontinuities and errors.
## 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.