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

@deltakit/markdown

v0.4.0

Published

Stream markdown in AI chat without flicker or broken syntax

Downloads

591

Readme

@deltakit/markdown

Streaming markdown renderer for AI chat UIs. Parses and renders markdown incrementally so settled blocks usually stay stable and partial syntax never flickers on screen. Zero dependencies beyond React.

Installation

npm install @deltakit/markdown

Requires React 18+.

Quick Start

import { StreamingMarkdown } from "@deltakit/markdown";

function AssistantMessage({ content }: { content: string }) {
  return <StreamingMarkdown content={content} />;
}

For completed/historical messages, use the lighter Markdown component:

import { Markdown, StreamingMarkdown } from "@deltakit/markdown";

function Message({ content, isStreaming }: { content: string; isStreaming: boolean }) {
  if (isStreaming) {
    return <StreamingMarkdown content={content} />;
  }
  return <Markdown content={content} />;
}

With useStreamChat from @deltakit/react:

import { useStreamChat } from "@deltakit/react";
import { Markdown, StreamingMarkdown } from "@deltakit/markdown";

function Chat() {
  const { messages, isLoading, sendMessage } = useStreamChat({
    api: "/api/chat",
  });

  return (
    <div>
      {messages.map((msg) => (
        <div key={msg.id}>
          {msg.parts
            .filter((p) => p.type === "text")
            .map((p, i) => {
              const isActive = isLoading && msg.role === "assistant";
              return isActive ? (
                <StreamingMarkdown key={i} content={p.text} />
              ) : (
                <Markdown key={i} content={p.text} />
              );
            })}
        </div>
      ))}
    </div>
  );
}

API

<StreamingMarkdown />

The main component for rendering actively streaming markdown. Settled blocks are memoized via React.memo, so only the active block normally updates unless later parsing extends the same block.

<StreamingMarkdown
  content={text}           // Markdown string (grows as tokens arrive)
  batchMs={16}             // Debounce interval in ms (default: 16)
  bufferIncomplete={true}  // Hold back unclosed syntax (default: true)
  className="prose"        // CSS class on wrapper div
  components={{            // Override any rendered element
    code: ({ language, children, inline }) => (
      inline ? <code>{children}</code> : <pre><code>{children}</code></pre>
    ),
  }}
/>

<Markdown />

Lightweight component for completed/historical messages. No batching, debouncing, or streaming styles.

<Markdown
  content={text}           // Complete markdown string
  className="prose"        // CSS class on wrapper div
  components={{...}}       // Same component overrides as StreamingMarkdown
/>

useStreamingMarkdown(options)

Headless hook for full control over rendering.

import { useStreamingMarkdown } from "@deltakit/markdown";

function CustomRenderer({ content }: { content: string }) {
  const { nodes, isComplete } = useStreamingMarkdown({
    content,
    batchMs: 16,
    bufferIncomplete: true,
  });

  return <div>{nodes}</div>;
}

parseIncremental(content, options?) (framework-agnostic)

The core parser, importable without React:

import { parseIncremental } from "@deltakit/markdown/core";

const result = parseIncremental("# Hello\n\nSome **bold** text");
// result.blocks   -- array of parsed Block objects
// result.buffered -- incomplete syntax held back from rendering

Supported Syntax

| Syntax | Element | |--------|---------| | # heading | h1 -- h6 | | **bold** | strong | | *italic* | em | | `code` | inline code | | ~~strike~~ | strikethrough | | [text](url) | link | | ![alt](src) | image (with loading skeleton) | | https://... | autolink | | ``` fenced blocks | code block | | - item / * item | unordered list | | 1. item | ordered list | | > quote | blockquote | | \| table \| | table (GFM-style) | | --- | horizontal rule | | blank line | paragraph break |

Streaming Behavior

  • Settled blocks normally avoid re-rendering via React.memo
  • Active block re-renders as new characters arrive
  • Code blocks show as empty <pre><code> shells until the closing fence arrives
  • Incomplete syntax (e.g. unclosed **, [) is buffered and hidden until resolved
  • Partial list markers (for example -, 1., #) are buffered until the line is confirmed
  • Table headers and trailing rows are buffered until the parser has enough complete lines to render them safely
  • batchMs debounces DOM updates to control render frequency (default: 16ms / ~60fps)

Performance

  • Singleton style injection -- one shared <style> tag regardless of how many instances are mounted
  • No wrapper DOM nodes -- blocks render as semantic elements (<h1>, <p>, <pre>) without extra <div> or <span> wrappers
  • Optimized list rendering -- simple list items skip full block parsing; nested content uses resetIds: false to avoid ID collisions
  • Static Markdown component -- skips all streaming overhead for completed messages

Bundle Size

12.0 KB minified / 3.8 KB gzipped. Zero runtime dependencies.

Documentation

Full documentation, guides, and examples at deltakit.dev.

License

MIT