/**
* AI SDK UI - Custom Message Renderer
*
* Demonstrates:
* - Markdown rendering (react-markdown)
* - Code syntax highlighting (react-syntax-highlighter)
* - Custom message components
* - Copy code button
* - Timestamp display
* - User avatars
*
* Dependencies:
* npm install react-markdown react-syntax-highlighter
* npm install --save-dev @types/react-syntax-highlighter
*
* Usage:
* 1. Install dependencies
* 2. Copy this component
* 3. Use
{children}
);
},
}}
>
{message.content}
With markdown, syntax highlighting, and copy buttons
Messages will render with markdown and syntax highlighting
${code}`;
});
// Inline code
text = text.replace(/`([^`]+)`/g, '$1');
// Bold
text = text.replace(/\*\*([^*]+)\*\*/g, '$1');
// Italic
text = text.replace(/\*([^*]+)\*/g, '$1');
// Line breaks
text = text.replace(/\n/g, '