← all repositories
antfu/shiki-stream

Syntax highlighting for code that doesn't know it's done yet

Turns incomplete text streams—think LLM outputs—into syntax-highlighted tokens on the fly, without buffering the entire response.

593 stars HTML Other AI
shiki-stream
Not currently ranked — collecting fresh signals.
star history

What it does

shiki-stream (now maintained as @shikijs/stream) is a Web Streams TransformStream that takes raw text chunk-by-chunk and emits themed Shiki tokens. It includes ready-made renderers for Vue, React, and Solid that consume the token stream directly, plus an experimental cached renderer for incrementally updated code strings.

The interesting bit

Syntax highlighters normally need full context to colorize correctly, but streams only flow forward. The library emits “recall” tokens when later chunks retroactively change how earlier text should be colored, letting consumers discard stale tokens instead of waiting for a complete response.

Key highlights

  • Built on standard Web Streams (ReadableStream, pipeThrough), so it works in browsers and Node.js
  • Framework-specific renderers for Vue, React, and Solid handle token consumption out of the box
  • allowRecalls toggle lets consumers choose between stable line-by-line output and fine-grained token updates
  • Includes an experimental ShikiCachedRenderer for incremental string updates instead of stream plumbing
  • The original shiki-stream package is now a thin re-export of @shikijs/stream; new code should use the scoped package

Caveats

  • The cached renderer API is marked experimental, and the React version is listed as TODO
  • Because syntax highlighting is context-sensitive, consumers must handle recall tokens or accept coarser-grained updates

Verdict

Grab it if you’re building chat UIs or live coding environments that need immediate feedback. If your code arrives all at once, plain Shiki is simpler and avoids the stream overhead.

Frequently asked

What is antfu/shiki-stream?
Turns incomplete text streams—think LLM outputs—into syntax-highlighted tokens on the fly, without buffering the entire response.
Is shiki-stream open source?
Yes — antfu/shiki-stream is open source, released under the MIT license.
What language is shiki-stream written in?
antfu/shiki-stream is primarily written in HTML.
How popular is shiki-stream?
antfu/shiki-stream has 593 stars on GitHub.
Where can I find shiki-stream?
antfu/shiki-stream is on GitHub at https://github.com/antfu/shiki-stream.

heatdrop uses Google Analytics to see which pages get read — nothing else. Your call. How we handle data.