@streamdown/mermaid package renders Mermaid diagrams from fenced code blocks tagged with the mermaid language identifier. It integrates with the plugins.mermaid field on <Streamdown>.
Installation
Quick start
createMermaidPlugin()
Creates aDiagramPlugin instance with optional configuration.
Optional configuration for the plugin.
DiagramPlugin interface
Discriminant for the plugin union type. Always
"diagram".Plugin identifier. Always
"mermaid".The fenced code block language that triggers this renderer. Always
"mermaid".Returns the shared
MermaidInstance. When config is provided, mermaidInstance.initialize(config) is called before returning, merging the supplied config over the plugin’s defaults. Subsequent calls without a config return the already-initialised instance.MermaidInstance interface
The object returned bygetMermaid(). It wraps the Mermaid library with lazy initialisation.
Initialises (or re-initialises) the Mermaid library with the supplied config, merged over plugin defaults. Safe to call multiple times; each call resets the running configuration.
Renders a Mermaid diagram source string to an SVG string.
id must be a unique DOM element identifier for Mermaid’s internal rendering. The returned svg is an inline SVG string ready to set as innerHTML.Mermaid is initialised with the plugin’s default config on the first render() call if initialize() has not been called beforehand.Per-render configuration
You can supply a customMermaidConfig at the component level via the mermaid prop on <Streamdown>. This is applied alongside the plugin and takes precedence for diagram rendering:
