xiaohongshu
xiaohongshu
hashbrown-dev
Building LLM-powered React applications with the Hashbrown library. Use when the user asks to (1) Build generative UI where LLMs render React components, (2) Add client-side tool calling for LLM-app interaction, (3) Stream LLM responses in React applications, (4) Execute LLM-generated JavaScript ...
Full skill instructions
Hashbrown is a React library for building LLM-powered applications with generative UI, client-side tool calling, streaming, and sandboxed JavaScript execution. It provides React hooks (useChat, useUiChat, etc.) that connect to a Node.js backend adapter, which securely communicates with LLM providers (OpenAI, Anthropic, Google, Azure, Bedrock, Ollama).
Architecture: React frontend (using Hashbrown hooks) + Node.js backend adapter (proxies LLM API requests)
| Hook | Multi-turn Chat | Single Input | Structured Output | Tool Calling | Generate UI |
|---|---|---|---|---|---|
useChat | ✅ | ❌ | ❌ | ✅ | ❌ |
useStructuredChat | ✅ | ❌ | ✅ | ✅ | ❌ |
useCompletion | ❌ | ✅ | ❌ | ✅ | ❌ |
useStructuredCompletion | ❌ | ✅ | ✅ | ✅ | ❌ |
useUiChat | ✅ | ❌ | ✅ | ✅ | ✅ |
Use the scripts to scaffold components and servers:
# List available templates
python scripts/list-templates.py
# Generate a component
python scripts/generate-component.py simple-chat ./src/components
# Generate a backend server
python scripts/generate-server.py basic-chat-server ./backend
Available component templates:
simple-chat - Basic text-only chat with useChatui-chat-with-components - Generative UI with useUiChat and exposeComponentclient-side-tool-calling - Tool calling with useTooljs-runtime-chart-generator - Sandboxed JS execution for data visualizationstructured-data-form - Form generation from natural language with Skillet schemasstreaming-chat-ui - Streaming responses with loading statesmulti-threaded-chat-ui - Multi-conversation management with threadspredictive-text-input - Autocomplete/suggestions powered by LLMchat-with-voice-input - Voice input with speech recognitionAvailable server templates:
basic-chat-server - Simple Express server with OpenAI adapterstreaming-chat-server - Streaming support for real-time responseschat-server-with-data - Server with database/context injectionchat-server-with-threads - Persistent conversation threadsserver-with-authentication - Auth-protected endpointsLoad reference documentation as needed for deep implementation details:
Expose React components to the LLM so it can render your UI dynamically.
import { useUiChat, exposeComponent } from '@hashbrownai/react'
import { s } from '@hashbrownai/core'
import { MyCard } from './MyCard'
const exposedCard = exposeComponent(MyCard, {
name: 'MyCard',
description: 'A card to display information',
props: { title: s.string('The title'), content: s.string('The body') },
})
const { messages } = useUiChat({
components: [exposedCard],
model: 'gpt-4',
system: 'Render cards to show information to the user.',
})
// messages[1].ui will contain <MyCard title="..." content="..." />
When to use: Build browser agents, dynamic dashboards, form builders, or any UI that should adapt based on LLM decisions.
Reference: See core-concepts.md for detailed component exposure patterns.
Allow the LLM to call client-side functions to access app state or perform actions.
import { useChat, useTool } from '@hashbrownai/react'
const getUserTool = useTool({
name: 'getUser',
description: 'Get current user information',
handler: async () => ({ name: 'Jane Doe' }),
deps: [],
})
const { messages } = useChat({
tools: [getUserTool],
model: 'gpt-4',
})
When to use: Let the LLM access application state, trigger actions, or interact with external APIs.
Reference: See core-concepts.md for tool definition patterns.
Use Skillet schemas to get type-safe, validated JSON from the LLM.
import { useStructuredCompletion } from '@hashbrownai/react'
import { s } from '@hashbrownai/core'
const schema = s.object('Response', {
name: s.string('User name'),
age: s.number('User age'),
interests: s.array('List of interests', s.string('An interest')),
})
const { data } = useStructuredCompletion({
schema,
model: 'gpt-4',
prompt: 'Extract user info: John is 30 and likes hiking and reading.',
})
// data will be typed as { name: string; age: number; interests: string[] }
When to use: Extract structured information, build forms from natural language, parse documents, or transform unstructured text to JSON.
Reference: See structured-data.md for Skillet schema language details.
Execute LLM-generated JavaScript safely in a WASM-based QuickJS sandbox.
import { useRuntime, useToolJavaScript, useChat } from '@hashbrownai/react'
const runtime = useRuntime({ functions: [] })
const jsTool = useToolJavaScript({ runtime })
const chat = useChat({ tools: [jsTool], model: 'gpt-4' })
When to use: Let the LLM perform complex calculations, data transformations, or generate visualizations using code.
Reference: See core-concepts.md for runtime configuration.
Connect to any LLM provider via backend adapters:
// Backend server (Node.js)
import { HashbrownOpenAI } from '@hashbrownai/openai'
const stream = HashbrownOpenAI.stream.text({
apiKey: process.env.OPENAI_API_KEY,
request,
})
Supported platforms: OpenAI, Anthropic, Google, Azure, Bedrock, Ollama, Writer, and custom adapters.
Reference: See platform-integration.md for all adapter configurations.
python scripts/generate-component.py simple-chat ./srcpython scripts/generate-server.py basic-chat-server ./backend<HashbrownProvider url="/api/chat">python scripts/generate-component.py ui-chat-with-components ./srcexposeComponent(Component, { name, description, props })useUiChat({ components: [...] })useTool({ name, description, handler })useChat({ tools: [...] })s.streaming modifier in Skillet schema:
const schema = s.object('Response', {
items: s.streaming.array('Items', s.string('Item')),
})
AbortSignal with timeout to JS runtimexiaohongshu
technical spec
product ux expert
database patterns
Conduct multi-agent task orchestration and workflow coordination.
Initialize project with Conductor artifacts (product definition,
Expert in web animations, transitions, and motion design using Framer Motion and CSS
Creates Mermaid and ASCII diagrams for flowcharts, architecture, ERDs, state machines, mindmaps, and more. Use when user mentions diagram, flowchart, mermaid, ASCII diagram, text diagram, terminal diagram, visualize, C4, mindmap, architecture diagram, sequence diagram, ERD, or needs visual docume...
PostgreSQL bindings for H3 hexagonal grid system. Use when working with H3 cells in Postgres, including spatial indexing, geometry/geography integration, and raster analysis.
Context-Driven Development skill for projects using Conductor. Use this skill when you detect a `conductor/` directory in the project, when working on tasks defined in a `plan.md` file, or when the user asks about tracks, specs, or plans. Automatically applies TDD workflow, tracks task completion...
Display project status, active tracks, and next actions
Official Stakpak application containerization standard operating procedure, a step-by-step guidline to properly dockerize applications. This is a rule book curated by the Stakpak Team.
Generate, edit, and beat-sync AI video with leading models in one workspace.
The world's fastest calendar for remote work
Transform Your Design with AI Designer by ImgCreator.ai
Revolutionizing Video Production with AI-Powered Creativity
Extend an image past the frame and let AI fill the new aspect ratio.
Discover your celebrity doppelgänger with StarByFace!
ChainClarity explains 700+ crypto whitepapers in plain English, with layered summaries, comparisons, research tools, alerts, and a $4.99 Pro plan.
Opus.ai: Revolutionize Your Web Experience