Hashbrown

Stream a structured sales dashboard through Hashbrown's UI kit and progressive JSON parser.

Not available for agent-spec yet

The code on this page comes from the showcase's declarative-hashbrown demo, and agent-spec doesn't have it yet. See this page for CopilotKit's Built-in Agent, LangGraph (Python), LangGraph (TypeScript).

You want a dashboard to appear while the agent is still answering. Hashbrown parses the agent's JSON as it streams and renders each finished component from your UI kit.

When to use this

  • Streaming dashboards that should appear before the full response arrives.
  • Agent-authored UI constrained to components you expose in a UI kit.
  • Apps already using Hashbrown for progressive JSON rendering.

For a validated { root, elements } spec that renders as one tree, see JSON Render. Its agent output and React API are different from Hashbrown's.

Frontend

The bundled demos pin @hashbrownai/core and @hashbrownai/react to 0.5.0-beta.4. The chart components also need recharts and zod.

  1. Wrap the chat in HashBrownDashboard. That provider creates the UI kit once and shares it with the assistant-message renderer.

  2. Register HashBrownRenderMessage in the assistantMessage slot of CopilotChat:

    chat.tsx
    <CopilotChat
      messageView={{
        assistantMessage:
          HashBrownRenderMessage as unknown as typeof CopilotChatAssistantMessage,
      }}
    />
  3. Tell the agent to answer with one { "ui": [...] } object, as shown in Backend.

The UI kit exposes metric, pieChart, barChart, dealCard, and Markdown with their prop schemas. The renderer parses the streamed message against the kit schema and renders what it has so far:

hashbrown-renderer.tsx (excerpt)
const { value } = useJsonParser(content, kit.schema);
if (!value) return null;
return <div>{kit.render(value)}</div>;

Chart data is a JSON-encoded string. The chart wrappers parse it before they pass an array to the chart components.

Backend

The agent sends one JSON object as the assistant message, without a Markdown fence or prose before it. Its top-level ui array contains component names from the kit. Each component has a props object matching its schema. For example:

example assistant message
{
  "ui": [
    { "metric": { "props": { "label": "Total Revenue", "value": "$1.2M" } } },
    {
      "pieChart": {
        "props": {
          "title": "Revenue by Segment",
          "data": "[{\"label\":\"Enterprise\",\"value\":600000},{\"label\":\"SMB\",\"value\":400000},{\"label\":\"Startup\",\"value\":200000}]"
        }
      }
    }
  ]
}

The bundled agents use this envelope and the same component names. The parser can render finished parts of ui while the rest of the JSON is still streaming.

How is this guide?