Setting up Streamdown in React
Start by installing Streamdown:
shell
npm i streamdownIf you're making a chatbot, then you'll probably want to do this as a part of
AI Elements provided by Vercel.
shell
npx ai-elements@latest add messageUse the <Streamdown /> component to render Markdown content:
tsx
import Streamdown from "streamdown";
// This is installed by default
import remarkGfm from "remark-gfm";
// This isn't installed by default
import remarkBreaks from "remark-breaks";
import { MyCustomLink } from "@/components/my-custom-link";
type MarkdownViewProps = {
content: string;
}
export function MarkdownView({ content }: MarkdownViewProps) {
return (
<Streamdown
// Optionally install plugins
remarkPlugins={[remarkGfm, remarkBreaks]}
// Optionally provide a component map
components={{
a: MyCustomLink,
}}
>
{content}
</Streamdown>
)
}