nextjs-chat/— ShopMetrics: e-commerce analytics demo with Next.js 16
cd nextjs-chat
cp .env.example .env.local # add API key
pnpm install
pnpm devsrc/app/api/chat/route.ts— system prompt + LLM streaming (Zod validated)src/app/mdoc-registry.ts— 24 component definitions with Zod schemassrc/app/mdoc-message.tsx— StreamingParser + Renderer integration with theme-aware classNamessrc/app/page.tsx— chat UI with action handling, theme switcher, streaming indicatorsrc/app/globals.css— chart/progress color overrides via data-* attributessrc/app/theme-provider.tsx— light/dark theme context with localStorage persistence
- Define components in registry with Zod schemas (
mdoc-registry.ts) - Call
generatePrompt(registry, options)to build system prompt — library auto-generates syntax/component docs, app adds domain rules and examples - Stream LLM response as
text/plainusing native Anthropic/OpenAI SDK - Parse on client with
StreamingParserfrom@mdocui/core - Render with
<Renderer>+defaultComponents+classNamesfor theming - Handle actions via
onActioncallback — buttons send follow-up messages, forms submit state
Always use pnpm publish not npm publish for the library packages. See AGENTS.md in the main repo.