---
title: "Event Stream hooks"
description: "React hooks for Aeontel event stream."
section: "Libraries"
group: "React hooks"
order: 418
---

## Hooks

### `useEventStream` `websocket`

Real-time event stream with automatic React Query cache invalidation.

Opens a WebSocket to the API's event stream for the given workspace.
Incoming events are debounced and batch-invalidate the relevant caches
so the UI updates in near-real-time.

```ts
useEventStream(workspaceId: string | undefined, options: UseEventStreamOptions = {})
```

```ts
// Basic — auto-invalidates all caches
const { connected } = useEventStream("wsp_...");

// With event callback
const { connected } = useEventStream("wsp_...", {
  onEvent: (event) => console.log(event),
  filter: ["run.completed", "agent.*"],
});
```
