# OpenCode Runtime
URL: /docs/runtimes/opencode/overview

Build a React chat UI for OpenCode coding agents with assistant-ui — streaming, tool calls, file edits, and terminal output rendered in chat.

> For AI agents: a documentation index is available at [llms.txt](/llms.txt). Use `.md` for canonical markdown pages; `.mdx` is kept as a backwards-compatible alias on supported URL paths.

`@assistant-ui/react-opencode` is a runtime adapter for [OpenCode](https://opencode.ai/), an open-source AI coding agent. It wires the OpenCode server's session and event APIs into an assistant-ui thread, including tool permissions, interactive questions, and session state.

> [!warn]
>
> This adapter is at v0.0.3 and is experimental. The runtime API and exported hooks may change without notice.

## When to use it

Pick the OpenCode runtime when:

- You are building a UI on top of an OpenCode agent server.
- You need first-class support for OpenCode's permission and question flows.
- You want session-aware features: fork, revert, unrevert, refresh.

If your backend is not OpenCode-based, see [picking a runtime](/docs/runtimes/pick-a-runtime) for alternatives.

## Architecture

`@assistant-ui/react-opencode` is layered on `ExternalStoreRuntime` plus a `RemoteThreadList` for session-backed thread management (see [architecture](/docs/runtimes/concepts/architecture)). OpenCode sessions map to assistant-ui threads; the runtime subscribes to a server-sent event stream and projects messages into the thread.

## Requirements

- A running [OpenCode](https://opencode.ai/) server (defaults to `http://localhost:4096`).
- React 18 or 19.

## Install

```bash
npm install @assistant-ui/react @assistant-ui/react-opencode @opencode-ai/sdk
```

## Next

- [Quickstart](/docs/runtimes/opencode/quickstart) — Minimal useOpenCodeRuntime setup against a local OpenCode server.
- [Hooks](/docs/runtimes/opencode/hooks) — Permissions, questions, session state, runtime extras.