# useChannel

> **Function** in `@langchain/react`

📖 [View in docs](https://reference.langchain.com/javascript/langchain-react/useChannel)

Raw-events escape hatch. Subscribes to one or more channels at a
namespace and returns a bounded buffer of raw protocol events.

The buffer keeps accumulating across serial runs for the lifetime of
the thread, so this is the hook to use for an event log / stream of a
custom channel (e.g. `["custom:redaction-stats"]`). When you only need
the latest payload of a single `custom:<name>` channel, prefer
useExtension. For the common message/tool/value cases prefer
useMessages / useToolCalls / useValues.

## Signature

```javascript
useChannel(stream: AnyStream, channels: readonly Channel[], target?: SelectorTarget, options?: ChannelProjectionOptions): Event[]
```

## Parameters

| Name | Type | Required | Description |
|------|------|----------|-------------|
| `stream` | `AnyStream` | Yes |  |
| `channels` | `readonly Channel[]` | Yes |  |
| `target` | `SelectorTarget` | No |  |
| `options` | `ChannelProjectionOptions` | No |  |

## Returns

`Event[]`

---

[View source on GitHub](https://github.com/langchain-ai/langgraphjs/blob/483e6df5eaf0f9a5ca4d682131ee431d77018369/libs/sdk-react/src/selectors.ts#L411)