npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2026 – Pkg Stats / Ryan Hefner

gen-streamdown

v1.2.0

Published

A customized fork of streamdown - a drop-in replacement for react-markdown, designed for AI-powered streaming.

Readme

gen-streamdown

A customized fork of streamdown - a drop-in replacement for react-markdown, designed for AI-powered streaming.

npm version

Overview

Formatting Markdown is easy, but when you tokenize and stream it, new challenges arise. This package is a customized fork of Streamdown, built specifically to handle the unique requirements of streaming Markdown content from AI models, providing seamless formatting even with incomplete or unterminated Markdown blocks.

This fork maintains all the features of the original streamdown package while allowing for customizations and extensions.

Features

  • 🚀 Drop-in replacement for react-markdown
  • 🔄 Streaming-optimized - Handles incomplete Markdown gracefully
  • 🎨 Unterminated block parsing - Build with remend for better streaming quality
  • 📊 GitHub Flavored Markdown - Tables, task lists, and strikethrough support
  • 🔢 Math rendering - LaTeX equations via KaTeX
  • 📈 Mermaid diagrams - Render Mermaid diagrams as code blocks with a button to render them
  • 📊 Vega-Lite charts - Render interactive Vega-Lite charts from JSON specs
  • 🎯 Code syntax highlighting - Beautiful code blocks with Shiki
  • 🛡️ Security-first - Built with rehype-harden for safe rendering
  • Performance optimized - Memoized rendering for efficient updates
  • 🎨 Customizable - Fork allows for custom components and styling

Installation

Install using your preferred package manager:

# npm
npm install gen-streamdown

# pnpm
pnpm add gen-streamdown

# yarn
yarn add gen-streamdown

# bun
bun add gen-streamdown

Peer Dependencies

Make sure you have React installed (required peer dependency):

# npm
npm install react

# pnpm
pnpm add react

# yarn
yarn add react

# bun
bun add react

Optional Dependencies

For full functionality, you may also want to install optional plugins:

# npm
npm install @streamdown/code @streamdown/math @streamdown/mermaid @streamdown/cjk

# pnpm
pnpm add @streamdown/code @streamdown/math @streamdown/mermaid @streamdown/cjk

# yarn
yarn add @streamdown/code @streamdown/math @streamdown/mermaid @streamdown/cjk

# bun
bun add @streamdown/code @streamdown/math @streamdown/mermaid @streamdown/cjk

Then, update your Tailwind globals.css to include the following so that Tailwind can detect the utility classes used by gen-streamdown.

@source "../node_modules/gen-streamdown/dist/*.js";

The path must be relative from your CSS file to the node_modules folder containing gen-streamdown. In a standard Next.js project where globals.css lives in app/, the default path above should work.

Monorepo setup

In a monorepo (npm workspaces, Turbo, pnpm, etc.), dependencies are typically hoisted to the root node_modules. You need to adjust the relative path to point there:

monorepo/
├── node_modules/gen-streamdown/  ← hoisted here
├── apps/
│   └── web/
│       └── app/
│           └── globals.css   ← your CSS file
/* apps/web/app/globals.css → 3 levels up to reach root node_modules */
@source "../../../node_modules/gen-streamdown/dist/*.js";

Adjust the number of ../ segments based on where your CSS file lives relative to the root node_modules.

Usage

Here's how you can use gen-streamdown in your React application:

import { Streamdown } from "gen-streamdown";
import { code } from "@streamdown/code";
import { mermaid } from "@streamdown/mermaid";
import { math } from "@streamdown/math";
import { cjk } from "@streamdown/cjk";
import "katex/dist/katex.min.css";
import "gen-streamdown/styles.css";

export default function Chat() {
  const [content, setContent] = useState("");

  return (
    <div>
      <Streamdown
        animated
        plugins={{ code, mermaid, math, cjk }}
        isAnimating={true}
      >
        {content}
      </Streamdown>
    </div>
  );
}

With AI SDK

import { useChat } from "@ai-sdk/react";
import { Streamdown } from "gen-streamdown";
import { code } from "@streamdown/code";
import { mermaid } from "@streamdown/mermaid";
import { math } from "@streamdown/math";
import { cjk } from "@streamdown/cjk";
import "katex/dist/katex.min.css";
import "gen-streamdown/styles.css";

export default function Chat() {
  const { messages, status } = useChat();

  return (
    <div>
      {messages.map(message => (
        <div key={message.id}>
          {message.role === 'user' ? 'User: ' : 'AI: '}
          {message.parts.map((part, index) =>
            part.type === 'text' ? (
              <Streamdown
                key={index}
                animated
                plugins={{ code, mermaid, math, cjk }}
                isAnimating={status === 'streaming'}
              >
                {part.text}
              </Streamdown>
            ) : null,
          )}
        </div>
      ))}
    </div>
  );
}

Vega-Lite Charts

To render Vega-Lite charts, use a code block with language vega-lite:

```vega-lite
{
  "$schema": "https://vega.github.io/schema/vega-lite/v5.json",
  "description": "A simple bar chart",
  "data": {
    "values": [
      {"a": "A", "b": 28},
      {"a": "B", "b": 55},
      {"a": "C", "b": 43}
    ]
  },
  "mark": "bar",
  "encoding": {
    "x": {"field": "a", "type": "ordinal"},
    "y": {"field": "b", "type": "quantitative"}
  }
}
```

The code block content should be a valid Vega-Lite JSON specification. The chart will be rendered automatically.

Customization

This fork allows you to customize components and styling. You can:

  • Modify components in the lib/ directory
  • Extend the component system for your use case
  • Customize styling through CSS variables and Tailwind config

Original Package

This is a fork of streamdown by Vercel. For the original package and documentation, visit:

License

Apache-2.0 (same as the original streamdown package)

Contributing

This is a customized fork. For contributions to the original streamdown project, please visit the original repository.