> ## Documentation Index
> Fetch the complete documentation index at: https://docs.towns.com/llms.txt
> Use this file to discover all available pages before exploring further.

# useTimeline

Hook to get the timeline events from a stream.

You can use the `useTimeline` hook to get the timeline events from a channel stream, dm stream or group dm stream

## Imports

```ts theme={null}
import { useTimeline } from '@towns-protocol/react-sdk'
```

## Examples

```ts theme={null}
import { useTimeline } from '@towns-protocol/react-sdk'
import { RiverTimelineEvent } from '@towns-protocol/sdk'

const { data: events } = useTimeline(streamId)

// You can filter the events by their kind
const messages = events.filter((event) => event.content?.kind === RiverTimelineEvent.ChannelMessage)
```

## Definition

```ts theme={null}
function useTimeline(
  streamId: string,
  config?: ObservableConfig.FromObservable<TimelineEvent[]>,
): ObservableValue<TimelineEvent[]>
```

**Source:** [useTimeline](https://github.com/towns-protocol/towns/blob/main/packages/react-sdk/src/useTimeline.ts)

## Parameters

### streamId

* **Type:** `string`

The id of the stream to get the timeline events from.

### config

* **Type:** `ObservableConfig.FromObservable<TimelineEvent[]>`
* **Optional**

Configuration options for the observable.

## Return Type

The timeline events of the stream as an observable.

```ts theme={null}
ObservableValue<TimelineEvent[]>
```
