Markdown streaming
When Markdown arrives incrementally - token by token from an LLM, for example - you can render it as it streams instead of waiting for the whole string. The display component fades in newly appended text and handles half-formed block elements gracefully while the rest is still arriving.
Streaming ships in the React Native package, on iOS and Android. streaming and streamingConfig are stripped on web, where the current Markdown string renders without the fade-in animation or the incomplete-block handling below; a stream still shows its text as it grows.
The standalone iOS and Android packages have no streaming API. You can still hand them a growing Markdown string and each update renders it, but new text does not fade in and half-formed tables, code blocks and math are not held back.
react-native-streamdown or streamingAnimationreact-native-streamdown is no longer needed: streaming is built into this package, which holds back incomplete blocks and repairs half-written Markdown itself, in native code, with no Worklets setup. See Migrating from react-native-streamdown for the steps.
streamingAnimation is deprecated in favor of streaming and logs a warning in development. It no longer only animates: while it is on, incomplete blocks are held back and inline syntax is repaired, so turn it off when the stream ends, or the final render keeps doing so.
Incremental rendering
Feed the growing Markdown string to the display component and set streaming while it arrives (off by default). Only the tail - the new characters beyond the previous content - fades in on each update, so the already-rendered text stays put. Set it back to false when the stream ends, so the final render shows everything; onStreamingEnd is called once the view has stopped streaming and the final render shows the whole text:
<EnrichedMarkdownText
markdown={partialMarkdown}
streaming={isStreaming}
onStreamingEnd={() => console.log('done')}
/>
The tail is found by length, not by diffing: everything past the previous string's length fades in. Streaming therefore assumes append-only updates. If you replace markdown wholesale - a retry, a regeneration, switching to a different response - the fade will not line up with what actually changed.
Animations
New content animates in through streamingConfig.animation:
// Each new word fades in over its own 200 ms (the default).
<EnrichedMarkdownText markdown={partial} streaming streamingConfig={{ animation: 'fade' }} />
// The last characters fade toward the end of the text, like a typewriter.
<EnrichedMarkdownText
markdown={partial}
streaming
streamingConfig={{
animation: { type: 'gradient', length: 15, startColor: '#107ACA', endColor: 'transparent' },
}}
/>
'fade'keeps time for each word on its own, so chunks arriving every frame still fade in fully, overlapping, and a word split across two chunks fades in as one.durationsets the text's time in milliseconds; blocks and table rows keep a 200 ms fade.'gradient'depends on each character's distance from the end, not on time: it follows the end of the text as it grows, and settles to the text's own colors over 200 ms when the stream ends. WithoutstartColoreach character keeps its own color (links, code, bold) and only fades toward the end.'none'shows new content at once; so does Reduce Motion.
Animations change only how characters are drawn, never the text, so selection, copy and accessibility see the text as it is. Blocks (tables, code blocks, images) fade in as a whole with 'fade' and 'gradient'.
Smooth pacing
Models and networks deliver text in bursts. streamingConfig.smooth reveals it word by word at a steady pace instead, the way chat apps do:
<EnrichedMarkdownText markdown={partial} streaming streamingConfig={{ smooth: true }} />
The view shows the text revealed so far, so lines, list items and blocks (tables, code blocks, images) grow with the words, and a view that scrolls to its end follows them line by line. Each chunk spreads over the time until the next one, so the pace follows the stream, at most a second behind; a word a chunk ends inside waits for the rest of it, and markdown such as a list marker or a heading's ## waits for the word after it, for at most half a second if the stream stalls. When the stream ends, what is left shows within 200 ms. It works with every animation: words fade in with 'fade', the gradient follows the words, and with 'none' words appear without fading. Reduce Motion keeps the pacing and turns off only the animation.
Streaming without re-rendering
Passing a growing markdown re-renders your component on every chunk, and hands the whole text from JavaScript to native code each time. With a stream, your component doesn't re-render: append chunks to it, and the view updates once per frame on its own. Its text stays in native memory, so only each chunk crosses from JavaScript.
import { createMarkdownStream } from 'react-native-enriched-markdown';
const stream = createMarkdownStream();
socket.onmessage = (event) => stream.append(event.data);
socket.onclose = () => stream.end();
<EnrichedMarkdownText stream={stream} flavor="github" />;
end() stops streaming and renders the whole text; reset() starts over for a retry. Keep the stream outside the component, so a row of a list that unmounts and mounts again shows the same text. See stream.
On web a stream shows its text as it grows, but onStreamingEnd does not fire.
Incomplete blocks
Some block elements can't be rendered until enough structure has arrived - a table needs its header and separator row, a fenced code block needs its closing fence. streamingConfig decides what happens in the meantime.
This handling, and the inline repair below, applies while streaming is on, in both flavors. Tables exist only in github, so tableMode has no effect under commonmark.
Tables (tableMode)
| Mode | Behavior |
|---|---|
'progressive' (default) | Renders the table row-by-row as content arrives; incomplete trailing rows are trimmed, and new rows fade in. |
'hidden' | Withholds the table until it is complete (followed by a blank line), avoiding partially-formed-table jank. |
Code blocks (codeBlockMode)
| Mode | Behavior |
|---|---|
'progressive' (default) | Streams the code line-by-line; with flavor="github" its header is visible but non-interactive (copying is disabled until the block completes); syntax highlighting is deferred until the closing fence so it does not flicker on every token. The block appears once the line that opens the fence has ended, so its language label never changes. |
'hidden' | Withholds the whole block until its closing fence arrives, then shows it complete. |
A code block drawn by renderers.code follows the same modes. In 'progressive' its element re-renders with the growing code and receives isComplete: false until the closing fence arrives.
Images, videos and links (mediaMode)
| Mode | Behavior |
|---|---|
'progressive' (default) | Shows a trailing image paragraph, link paragraph or <video> block once its syntax is complete. A half-streamed  and a lone marker line (-,#) wait until they can render.
The repair applies only to the unfinished tail; blocks that have finished render as written.
import { EnrichedMarkdownText } from 'react-native-enriched-markdown';
import { useEffect, useState } from 'react';
const fence = '```';
const full = `Here is what I found.
| Model | Score |
| ----- | ----: |
| A | 91 |
| B | 87 |
${fence}ts
const best = results.at(0);
${fence}
`;
export default function App() {
const [markdown, setMarkdown] = useState('');
// Reveal the document a few characters at a time to imitate an LLM stream.
useEffect(() => {
let i = 0;
const id = setInterval(() => {
i += 4;
setMarkdown(full.slice(0, i));
if (i >= full.length) clearInterval(id);
}, 60);
return () => clearInterval(id);
}, []);
// Streaming ends once the whole document has arrived.
return (
<EnrichedMarkdownText
markdown={markdown}
flavor="github"
streaming={markdown.length < full.length}
streamingConfig={{ tableMode: 'hidden', codeBlockMode: 'progressive' }}
/>
);
}
Migrating from react-native-streamdown
Streaming is built into this package, so react-native-streamdown is no longer needed:
- Replace
StreamdownTextwithEnrichedMarkdownTextand setstreamingwhile the text arrives. The other props carry over, sinceStreamdownTextaccepted everyEnrichedMarkdownTextprop. - Turn
streamingoff when the stream ends;StreamdownTexthad no such step. A view left streaming keeps holding back incomplete blocks in the final render. - Drop
remendConfig. It has no equivalent: repair of incomplete Markdown is built in. - Uninstall
react-native-streamdownandremend. - If nothing else in your app uses Worklets Bundle Mode, remove its setup:
bundleMode: trueand theimportForwardingentry forremendinbabel.config.js, thegetBundleModeMetroConfigentry inmetro.config.js, and the Metro patch.
// Before
<StreamdownText markdown={partialMarkdown} />
// After
<EnrichedMarkdownText markdown={partialMarkdown} streaming={isStreaming} />
Reference
streaming- set while the markdown is still arriving. Defaults tofalse. Replaces the deprecatedstreamingAnimation.stream- markdown fromcreateMarkdownStream(), updated once per frame without re-rendering your component.onStreamingEnd- called when the view stops streaming, after the last words have appeared.streamingConfig-tableMode,codeBlockModeandmediaMode, each'progressive'or'hidden',animation:'fade','gradient','none', or a preset with its options, andsmooth. Needsstreaming.- Markdown flavors - what else the flavor switch changes.