React frontend demonstrating AIDK client integration with hooks.
- Backend running at
http://localhost:3000(see express/README.md)
cd example
pnpm dev:reactOpens at http://localhost:5173
- Chat Interface - Streaming agent responses with markdown rendering
- Todo List - Real-time sync via channels
- Scratchpad - Thread-scoped notes synced across components
- Content Blocks - Renders text, code, tool calls, reasoning
Creates and manages the AIDK client connection:
const { client } = useEngineClient({
baseUrl: "http://localhost:3000",
userId: "demo-user",
callbacks: {
onConnect: () => console.log("Connected"),
onError: (err) => console.error(err),
},
});Handles agent execution and message streaming:
const { messages, isStreaming, sendMessage, clearMessages } = useExecution({
client,
agentId: "task-assistant",
});
// Send a message
sendMessage("Create a task to buy groceries");Subscribes to the todo list channel:
const { tasks, createTask, toggleComplete, deleteTask } = useTodoList(
client,
userId
);Subscribes to the scratchpad channel (thread-scoped):
const { notes, addNote, removeNote, clearNotes } = useScratchpad(
client,
threadId
);src/
├── App.tsx # Main app with all hooks wired up
├── components/
│ ├── ChatInterface.tsx # Chat UI with message list
│ ├── TodoListUI.tsx # Todo list component
│ └── ScratchpadUI.tsx # Scratchpad notes
└── hooks/
├── useEngineClient.ts # Client setup
├── useExecution.ts # Agent execution
├── useTodoList.ts # Todo channel
└── useScratchpad.ts # Scratchpad channel
Create a .env file:
VITE_API_URL=http://localhost:3000
pnpm build
pnpm preview