@streamdown/math package renders mathematical expressions using KaTeX. It provides remark and rehype plugins that parse and render $...$ inline math and $$...$$ block math, and integrates with the plugins.math field on <Streamdown>.
Installation
You must also import the KaTeX stylesheet in your application. Add the following import at the top of your root layout or CSS entry point:
Quick start
createMathPlugin()
Creates aMathPlugin instance with optional configuration.
Optional configuration for the plugin.
MathPlugin interface
Discriminant for the plugin union type. Always
"math".Plugin identifier. Always
"katex".A unified
Pluggable that configures remark-math to parse math syntax in the Markdown AST. Streamdown adds this to the remark pipeline automatically when the plugin is present.A unified
Pluggable that configures rehype-katex to render math nodes as KaTeX HTML. Streamdown adds this to the rehype pipeline automatically when the plugin is present.Returns the path to the KaTeX CSS file (
"katex/dist/katex.min.css"). You should import this stylesheet in your application rather than calling this method; it is provided as a reference.Math syntax
With the plugin enabled, the following syntax is supported: Inline math — wrap an expression in$...$:
Single-dollar inline math is disabled by default. Pass
singleDollarTextMath: true to createMathPlugin() to enable it.$$...$$:
$$...$$ inline without surrounding newlines:
Plugin ordering
Streamdown insertsremarkPlugin and rehypePlugin in the correct position relative to other plugins:
remarkPluginruns afterremark-gfmand any CJK remark plugins.rehypePluginruns after the default rehype sanitisation plugins.
