typewriter-sse
v1.0.0
Published
A simple typewriter effect with SSE streaming support
Readme
typewriter-sse
A minimal library to render typewriter-style text streamed over Server-Sent Events (SSE). Ideal for building ChatGPT-style effects.
📦 Installation
npm install typewriter-sse🚀 Usage
import TypewriterSSE from 'typewriter-sse';
const writer = new TypewriterSSE({
container: '#output',
endpoint: '/sse?q=hello world',
cursor: {
blink: true,
color: '#0f0',
char: '|'
},
onComplete: () => console.log('Finished typing!')
});
writer.start();⚙️ Options
| Option | Type | Description |
|--------------|----------|------------------------------------------|
| container | string \| HTMLElement | Target container |
| endpoint | string | SSE endpoint URL |
| typingSpeed | number | Delay per character (ms) |
| cursor | object | { blink, color, char } |
| onChar | fn | Callback on each char |
| onComplete | fn | Callback when stream ends |
🧪 Demo
Run the example below:
cd demo
npm install
node server.jsThen visit: http://localhost:3000
