# useTransport
The `useTransport` hook returns the [transport](https://ably.com/docs/ai-transport/api/javascript/transport/transport.md) from the nearest `TransportProvider`, or from the provider for a channel name you pass. Use it to send messages, pipe events, or subscribe with history replay from a component.
Transport unavailable: {error.message} Transport unavailable: {error.message}
#### OpenAI Javascript
```
import { useTransport } from '@ably/ai-transport/react';
function Composer({ channelName }) {
const { transport, error } = useTransport();
if (error) return
This hook must be used within a [`TransportProvider`](https://ably.com/docs/ai-transport/api/react/transport-provider.md).
## Parameters
### Javascript
```
import { useEffect } from 'react';
import { fromSerial } from '@ably/ai-transport';
import { useTransport } from '@ably/ai-transport/react';
function Conversation({ storedSerial, onDelivery }) {
const { transport } = useTransport();
useEffect(() => {
if (!transport) return;
const unsubscribe = transport.subscribe(onDelivery, {
history: storedSerial ? { replay: fromSerial(storedSerial) } : undefined,
});
return () => unsubscribe();
}, [transport, storedSerial, onDelivery]);
return 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.
- [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.
- [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.