# ThreadRuntime
URL: /docs/api-reference/runtimes/thread-runtime

Runtime for thread state, messages, and viewport management.

***

title: ThreadRuntime
description: Runtime for thread state, messages, and viewport management.
-------------------------------------------------------------------------

import { ParametersTable } from "@/components/docs/tables/ParametersTable";
import { ThreadRuntime, ThreadState } from "@/generated/typeDocs";
import { ThreadMessagesState, ThreadViewportState } from "@/components/docs/tables/parameters/context";

### `useThreadRuntime`

Get the thread runtime object:

```tsx
import { useThreadRuntime } from "@assistant-ui/react";

const thread = useThreadRuntime();
```

<ParametersTable {...ThreadRuntime} />

### `useThread`

Access the thread state directly:

```tsx
import { useThread } from "@assistant-ui/react";

const thread = useThread();
const isRunning = useThread((m) => m.isRunning);
const isLoading = useThread((m) => m.isLoading);
```

<ParametersTable {...ThreadState} />

### `useThreadViewport`

Manage thread viewport state (e.g., scrolling):

```tsx
import { useThreadViewport } from "@assistant-ui/react";

const threadViewport = useThreadViewport();
const isAtBottom = useThreadViewport((m) => m.isAtBottom);
```

<ParametersTable {...ThreadViewportState} />
