Skip to content
Star

LangChain useStream

Render a LangChain conversation and keep graph state and interrupts in the native hook.

Connect the React hook

Install Ghost UI and its view dependencies, then add the tested LangChain packages.

Install dependencies

Pass your graph’s apiUrl, assistantId, and native thread ID. Keep credentials in your app’s server proxy. See the LangChain frontend setup guide to configure the graph connection.

langchain-conversation.tsx

The adapter reads actual BaseMessage instances or serialized messages, including tool IDs and removal records. It binds text send to native submit({ messages: [...] }) and stop to native stop(). Compose Composer with runtime.controller for input; the native hook remains available in the same component.

Fork and resume deliberately

langchain-native-commands.ts

stream.values holds custom graph state; validate it for your application panel. isThreadLoading hydrates history and disables send; isLoading describes active work. Native stop() requests server cancellation; disconnect() stops observing without the same cancellation meaning. Checkpoint editing, branch navigation and typed interrupts remain native capabilities, not aliases for Ghost retry/edit/approval.

Troubleshooting

If records are missing IDs, use getId with a stable application key. Keep one hook per thread and revision and retain native checkpoint IDs when saving history. Use the LangGraph SDK recipe for a client managed outside React.