Streaming Markdown in Vue 3
Append incoming chunks to a reactive string and pass it to text. streaming controls unfinished syntax repair, smooth output and trailing effects.
Connect a text stream
This example consumes an async iterator of text. Decode SSE or other transport formats in your request layer:
Call read(chunks) after starting the request. Turn off streaming when the response ends. The component finishes any remaining smooth output before removing the trailing effect.
Adjust the output
streaming: true enables trailing repair, smooth output and the scale effect. Pass an object to configure each part:
Turn off smooth to keep the original chunk timing. See Core streaming for custom tickers and schedulers.
Four trailing effects
For example, preserve network chunks and fade them in one at a time:
effect also accepts [name, options] or an array of effects. See configuration for details and Animation for demos of all four effects.
Switch messages
Give each message its own component and use the message identifier as its key. Vue creates fresh streaming state when a different message replaces it.