Skip to content

LangChain useStream

Use native graph state, messages and interrupts without another transcript store.

Bind the React hook

Install @langchain/react@1.2.9 and its native peers; see checked versions and view setup. Supply your deployed graph's apiUrl, assistantId and native thread ID. Keep credentials in your application proxy.

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

Missing IDs need a stable application getId mapping, not positional keys. Keep one hook owner per thread/revision, and preserve native checkpoint IDs across persistence. If you own the client outside React, use the direct LangGraph recipe. See LangChain frontend documentation for native configuration and reconnection.