streamdown 0.0.5 → 1.0.5

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (2) hide show
  1. package/README.md +144 -0
  2. package/package.json +3 -2
package/README.md ADDED
@@ -0,0 +1,144 @@
1
+ # Streamdown
2
+
3
+ A drop-in replacement for react-markdown, designed for AI-powered streaming.
4
+
5
+ [![npm version](https://img.shields.io/npm/v/streamdown)](https://www.npmjs.com/package/streamdown)
6
+
7
+ ## Overview
8
+
9
+ Formatting Markdown is easy, but when you tokenize and stream it, new challenges arise. Streamdown is built specifically to handle the unique requirements of streaming Markdown content from AI models, providing seamless formatting even with incomplete or unterminated Markdown blocks.
10
+
11
+ Streamdown powers the [AI Elements Response](https://ai-sdk.dev/elements/components/response) component but can be installed as a standalone package for your own streaming needs.
12
+
13
+ ## Features
14
+
15
+ - 🚀 **Drop-in replacement** for `react-markdown`
16
+ - 🔄 **Streaming-optimized** - Handles incomplete Markdown gracefully
17
+ - 🎨 **Unterminated block parsing** - Styles incomplete bold, italic, code, links, and headings
18
+ - 📊 **GitHub Flavored Markdown** - Tables, task lists, and strikethrough support
19
+ - 🔢 **Math rendering** - LaTeX equations via KaTeX
20
+ - 🎯 **Code syntax highlighting** - Beautiful code blocks with Shiki
21
+ - 🛡️ **Security-first** - Built on harden-react-markdown for safe rendering
22
+ - ⚡ **Performance optimized** - Memoized rendering for efficient updates
23
+
24
+ ## Installation
25
+
26
+ ```bash
27
+ npm i streamdown
28
+ ```
29
+
30
+ Then, update your Tailwind `globals.css` to include the following:
31
+
32
+ ```css
33
+ @source "../node_modules/streamdown/dist/index.js";
34
+ ```
35
+
36
+ This will ensure that the Streamdown styles are applied to your project.
37
+
38
+ ## Usage
39
+
40
+ ### Basic Example
41
+
42
+ ```tsx
43
+ import { Streamdown } from 'streamdown';
44
+
45
+ export default function Page() {
46
+ const markdown = "# Hello World\n\nThis is **streaming** markdown!";
47
+
48
+ return <Streamdown>{markdown}</Streamdown>;
49
+ }
50
+ ```
51
+
52
+ ### With AI SDK
53
+
54
+ ```tsx
55
+ 'use client';
56
+
57
+ import { useChat } from '@ai-sdk/react';
58
+ import { useState } from 'react';
59
+ import { Streamdown } from 'streamdown';
60
+
61
+ export default function Page() {
62
+ const { messages, sendMessage, status } = useChat();
63
+ const [input, setInput] = useState('');
64
+
65
+ return (
66
+ <>
67
+ {messages.map(message => (
68
+ <div key={message.id}>
69
+ {message.parts.filter(part => part.type === 'text').map((part, index) => (
70
+ <Streamdown key={index}>{part.text}</Streamdown>
71
+ ))}
72
+ </div>
73
+ ))}
74
+
75
+ <form
76
+ onSubmit={e => {
77
+ e.preventDefault();
78
+ if (input.trim()) {
79
+ sendMessage({ text: input });
80
+ setInput('');
81
+ }
82
+ }}
83
+ >
84
+ <input
85
+ value={input}
86
+ onChange={e => setInput(e.target.value)}
87
+ disabled={status !== 'ready'}
88
+ placeholder="Say something..."
89
+ />
90
+ <button type="submit" disabled={status !== 'ready'}>
91
+ Submit
92
+ </button>
93
+ </form>
94
+ </>
95
+ );
96
+ }
97
+ ```
98
+
99
+ ## Props
100
+
101
+ Streamdown accepts all the same props as react-markdown, plus additional streaming-specific options:
102
+
103
+ | Prop | Type | Default | Description |
104
+ |------|------|---------|-------------|
105
+ | `children` | `string` | - | The Markdown content to render |
106
+ | `parseIncompleteMarkdown` | `boolean` | `true` | Parse and style unterminated Markdown blocks |
107
+ | `className` | `string` | - | CSS class for the container |
108
+ | `components` | `object` | - | Custom component overrides |
109
+ | `remarkPlugins` | `array` | `[remarkGfm, remarkMath]` | Remark plugins to use |
110
+ | `rehypePlugins` | `array` | `[rehypeKatex]` | Rehype plugins to use |
111
+ | `allowedImagePrefixes` | `array` | `['*']` | Allowed image URL prefixes |
112
+ | `allowedLinkPrefixes` | `array` | `['*']` | Allowed link URL prefixes |
113
+
114
+ ## Architecture
115
+
116
+ Streamdown is built as a monorepo with:
117
+
118
+ - **`packages/streamdown`** - The core React component library
119
+ - **`apps/website`** - Documentation and demo site
120
+
121
+ ## Development
122
+
123
+ ```bash
124
+ # Install dependencies
125
+ pnpm install
126
+
127
+ # Run development server
128
+ pnpm dev
129
+
130
+ # Run tests
131
+ pnpm test
132
+
133
+ # Build packages
134
+ pnpm build
135
+ ```
136
+
137
+ ## Requirements
138
+
139
+ - Node.js >= 18
140
+ - React >= 19.1.1
141
+
142
+ ## Contributing
143
+
144
+ Contributions are welcome! Please feel free to submit a Pull Request.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "streamdown",
3
- "version": "0.0.5",
3
+ "version": "1.0.5",
4
4
  "type": "module",
5
5
  "main": "./dist/index.js",
6
6
  "module": "./dist/index.js",
@@ -13,7 +13,8 @@
13
13
  }
14
14
  },
15
15
  "files": [
16
- "dist"
16
+ "dist",
17
+ "README.md"
17
18
  ],
18
19
  "scripts": {
19
20
  "build": "tsup",