Streamdown component is the main entry point for rendering Markdown in your application. It handles both static and live-streaming content, parses Markdown into optimally memoized blocks, applies syntax highlighting, animations, and more.
Props
The raw Markdown string to render. Streamdown expects a plain string. In streaming mode, pass the full accumulated content on every update — Streamdown will efficiently reconcile the diff.
Controls how Streamdown processes and renders content.
"streaming"— Parses the Markdown into discrete blocks, applies incomplete-markdown handling viaremend, and uses React Transitions to batch block updates without blocking the UI."static"— Renders the entire Markdown string in a single pass. Skips incomplete-markdown preprocessing and animation callbacks. Use this for already-complete content.
In
"static" mode, onAnimationStart and onAnimationEnd are suppressed even if isAnimating changes.Text direction applied to rendered blocks.
"auto"— Detects direction per block using the Unicode first-strong-character algorithm. Each block gets its owndirattribute."ltr"/"rtl"— Applies the given direction to all blocks.
dir attribute is added and the browser inherits direction from the DOM.When
true, signals that content is currently being streamed. Used to:- Show the caret character (if
caretis set) - Activate the
animatedentrance animation on new content - Mark the last block as incomplete for components that need it
- Trigger
onAnimationStart/onAnimationEndcallbacks
Enables per-word or per-character entrance animations on newly streamed content. Set to
true for defaults, or pass an AnimateOptions object to customize.Already-rendered content is never re-animated when new tokens arrive. Streamdown tracks the previous render’s character count and skips animation for those positions.Displays a blinking caret character after the last rendered character when
isAnimating is true."block"— renders▋"circle"— renders●
Additional CSS class name(s) applied to the outer
<div> wrapper. Combined with Streamdown’s default layout classes (space-y-4 whitespace-normal).Optional plugin bundle providing syntax highlighting, math, diagram, and CJK support.
Options forwarded to the remend preprocessor, which repairs incomplete Markdown syntax during streaming. Only applies in
mode="streaming" when parseIncompleteMarkdown is true.Configures which controls appear on interactive blocks (code blocks, tables, Mermaid diagrams). Pass
true to enable all controls, false to disable all, or an object for granular control.See ControlsConfig for the full type.A tuple of
[lightTheme, darkTheme] passed to Shiki for syntax highlighting. Accepts any BundledTheme string or a custom ThemeRegistrationAny object.When using the
@streamdown/code plugin, its getThemes() result takes precedence over this prop.Options for Mermaid diagram rendering. See
MermaidOptions.Configuration for the link safety confirmation modal shown before navigating to external URLs. See
LinkSafetyConfig.Show line numbers in code blocks.
Allow custom HTML tags through the sanitization layer. Provide a map of tag names to their permitted attributes.The type is
Record<string, string[]> where keys are tag names and values are arrays of allowed attribute names.This only works with the default
rehypePlugins. If you supply custom rehype plugins that replace the default sanitizer, you must handle custom tags within those plugins.Tags whose children should be treated as plain text instead of parsed Markdown. Useful for custom entity tags in AI UIs (e.g.
<mention>) where child text contains Markdown metacharacters that should not be interpreted.The tag must also be present in allowedTags.Override UI strings for internationalisation or custom labels. Merged with the built-in
defaultTranslations.Override the default SVG icons used in controls (copy, download, fullscreen, etc.). Provide a partial map — only the icons you specify are replaced.
Tailwind CSS prefix to prepend to all internal utility classes. For example,
prefix="tw" produces tw:flex instead of flex, enabling Tailwind v4’s prefix() support.User-supplied
className values are also prefixed when this option is set.When
true (in mode="streaming"), runs the remend preprocessor over the incoming Markdown before rendering to repair incomplete syntax (unclosed bold, partial code fences, etc.).Set to false if your content is always complete or you want to handle preprocessing yourself.When
true, strips 4+ leading spaces or tabs from HTML tags at the start of lines before parsing. This prevents Markdown parsers from treating deeply indented HTML as code blocks.Useful when rendering AI-generated HTML with nested tags indented for readability.Replaces the built-in See Block for the full
Block component used to render each parsed Markdown block. Use this to wrap blocks with custom logic, add per-block error boundaries, or instrument rendering.BlockProps reference.Replaces the default
parseMarkdownIntoBlocks function used to split the Markdown string into discrete blocks. Each block is rendered by a separate BlockComponent instance, enabling fine-grained memoisation.The default implementation splits on double newlines while preserving code fences and other multi-line structures.Called when
isAnimating transitions from false to true. Also called on mount if isAnimating is initially true.Suppressed when mode="static".Called when
isAnimating transitions from true to false.Suppressed when mode="static" and not called on the initial render.Custom React components to replace built-in HTML renderers. Based on the
react-markdown Components type — any intrinsic HTML element tag can be overridden.An additional inlineCode key is supported to target inline <code> elements separately from block code.Array of unified rehype plugins applied during HTML processing.Defaults to
defaultRehypePlugins (rehype-raw, rehype-sanitize, rehype-harden). Replacing this array removes the default sanitization pipeline — ensure you add your own sanitization if you accept untrusted content.Array of unified remark plugins applied during Markdown parsing.Defaults to
defaultRemarkPlugins (remark-gfm, remarkCodeMeta). Plugin plugins from the plugins prop (math, CJK) are merged in automatically in the correct order.Context
StreamdownContext
StreamdownContext is a React context exported from streamdown that child components — including custom components, BlockComponent, and plugin renderers — can read to access Streamdown’s resolved configuration.
StreamdownContextType:
The resolved
controls configuration.Whether the component is currently in an animating/streaming state.
Whether line numbers are enabled for code blocks.
The resolved link safety configuration.
The resolved Mermaid options.
The current rendering mode.
The active Shiki theme pair (light, dark). If a
CodeHighlighterPlugin is provided, this reflects the plugin’s themes.Default plugins
defaultRehypePlugins
An object (keyed by plugin name) containing the default rehype plugin pipeline:raw(rehype-raw) — Parses raw HTML nodes produced by remark-rehype back into a proper HAST tree.sanitize(rehype-sanitize) — Strips disallowed HTML elements and attributes using a schema derived fromrehype-sanitize’sdefaultSchema, extended to allowtel:hrefs andmetastringon<code>elements.harden(rehype-harden) — Hardens URLs and origins for safe rendering.
defaultRemarkPlugins
An object (keyed by plugin name) containing the default remark plugin pipeline:gfm(remark-gfm) — Adds GitHub Flavored Markdown support: tables, task lists, strikethrough, autolinks.codeMeta(remarkCodeMeta) — Exposes the raw metastring from code fences (everything after the language identifier) as ametastringprop on<code>elements.
Other exports
createAnimatePlugin
AnimatePlugin instance for tracking per-block animation state. You only need this when building a custom BlockComponent — the Streamdown component creates and manages its own plugin internally when animated is set.
The AnimatePlugin interface:
defaultTranslations
The default English strings for all translatable UI labels. Import and spread this to build partial translation overrides:defaultUrlTransform
The default URL transform function fromreact-markdown. Passed as the urlTransform prop default. Import to extend or replace it:
