langgraph.json
configuration:
ui
section points to the UI components that will be used by graphs. By default, we recommend using the same key as the graph name, but you can split out the components however you like, see Customise the namespace of UI components for more details.
LangGraph Platform will automatically bundle your UI components code and styles and serve them as external assets that can be loaded by the LoadExternalComponent
component. Some dependencies such as react
and react-dom
will be automatically excluded from the bundle.
CSS and Tailwind 4.x is also supported out of the box, so you can freely use Tailwind classes as well as shadcn/ui
in your UI components.
useStream()
and LoadExternalComponent
to display the UI elements.
LoadExternalComponent
will fetch the JS and CSS for the UI components from LangGraph Platform and render them in a shadow DOM, thus ensuring style isolation from the rest of your application.
LoadExternalComponent
will use the assistantId
from useStream()
hook to fetch the code for UI components. You can customise this by providing a namespace
prop to the LoadExternalComponent
component.
useStreamContext
hook.
meta
prop to the LoadExternalComponent
component.
meta
prop in the UI component by using the useStreamContext
hook.
onCustomEvent
callback of the useStream()
hook. This is especially useful when updating the UI component as the LLM is generating the response.
ui.push()
/ push_ui_message()
with the same ID as the UI message you wish to update.
remove_ui_message
/ ui.delete
with the ID of the UI message.