vue-markdown-render

vue-markdown-render

A Vue 3 renderer specifically built for AI-powered streaming Markdown: Monaco incremental, Mermaid progressive, and KaTeX formula speed, with real-time updates and no jitter, ready to use out of the box.

Stars: 280

Visit
 screenshot

vue-renderer-markdown is a high-performance tool designed for streaming and rendering Markdown content in real-time. It is optimized for handling incomplete or rapidly changing Markdown blocks, making it ideal for scenarios like AI model responses, live content updates, and real-time Markdown rendering. The tool offers features such as ultra-high performance, streaming-first design, Monaco integration, progressive Mermaid rendering, custom components integration, complete Markdown support, real-time updates, TypeScript support, and zero configuration setup. It solves challenges like incomplete syntax blocks, rapid content changes, cursor positioning complexities, and graceful handling of partial tokens with a streaming-optimized architecture.

README:

vue-renderer-markdown

Rendering Markdown is straightforward, but when you need to stream and render it in real-time, new challenges emerge. vue-renderer-markdown is built specifically to handle the unique requirements of streaming Markdown content from AI models and live updates, providing seamless formatting even with incomplete or rapidly changing Markdown blocks.

NPM version

πŸš€ Live Demo

Experience the power of high-performance streaming Markdown rendering in action!

Features

  • ⚑ Ultra-High Performance: Optimized for real-time streaming with minimal re-renders and efficient DOM updates
  • 🌊 Streaming-First Design: Built specifically to handle incomplete, rapidly updating, and tokenized Markdown content
  • 🧠 Monaco Streaming Updates: High-performance Monaco integration with smooth, incremental updates for large code blocks
  • πŸͺ„ Progressive Mermaid Rendering: Diagrams render as they become valid and update incrementally without jank
  • 🧩 Custom Components: Seamlessly integrate your Vue components within Markdown content
  • πŸ“ Complete Markdown Support: Tables, math formulas, emoji, checkboxes, code blocks, and more
  • πŸ”„ Real-Time Updates: Handles partial content and incremental updates without breaking formatting
  • πŸ“¦ TypeScript First: Full type definitions with intelligent auto-completion
  • πŸ”Œ Zero Configuration: Drop-in component that works with any Vue 3 project out of the box

Install

pnpm add vue-renderer-markdown
# or
npm install vue-renderer-markdown
# or
yarn add vue-renderer-markdown

Install peer dependencies (important)

This package declares a number of peer dependencies that your project must also install in order for vue-renderer-markdown to work correctly (for example: vue, vue-i18n, mermaid, katex, etc.). If these are missing you will see warnings and the component may fail at runtime.

Run one of the commands below from your project root to install the common peers listed in this repository's package.json:

pnpm (recommended):

pnpm add vue @iconify/vue @vueuse/core katex mermaid vue-use-monaco

npm:

npm install vue @iconify/vue @vueuse/core katex mermaid vue-use-monaco

yarn:

yarn add vue @iconify/vue @vueuse/core katex mermaid vue-use-monaco

Notes:

  • The versions installed will default to the latest matching releases; the exact peer version ranges are declared in this package's package.json β€” consult it if you need specific versions.
  • Some peers (for example vue-use-monaco / monaco-editor) are optional depending on which features you plan to use β€” install only the ones you need.
  • If you're installing this library inside a monorepo or using pnpm workspaces, install peers at the workspace root so they are available to consuming packages.

Why vue-renderer-markdown?

Streaming Markdown content from AI models, live editors, or real-time updates presents unique challenges:

  • Incomplete syntax blocks can break traditional parsers
  • Rapid content changes cause excessive re-renders and performance issues
  • Cursor positioning becomes complex with dynamic content
  • Partial tokens need graceful handling without visual glitches

vue-renderer-markdown solves these challenges with a streaming-optimized architecture that maintains perfect formatting and performance, even with the most demanding real-time scenarios.

Usage

Streaming Markdown (Recommended)

Perfect for AI model responses, live content updates, or any scenario requiring real-time Markdown rendering:

<script setup lang="ts">
import { ref } from 'vue'
import MarkdownRender from 'vue-renderer-markdown'

const content = ref('')
const fullContent = `# Streaming Content\n\nThis text appears character by character...`

// Simulate streaming content
let index = 0
const interval = setInterval(() => {
  if (index < fullContent.length) {
    content.value += fullContent[index]
    index++
  }
  else {
    clearInterval(interval)
  }
}, 50)
</script>

<template>
  <MarkdownRender :content="content" />
</template>

Basic Usage

For static or pre-generated Markdown content:

<script setup lang="ts">
import MarkdownRender from 'vue-renderer-markdown'

const markdownContent = `
# Hello Vue Markdown

This is **markdown** rendered as HTML!

- Supports lists
- [x] Checkboxes
- :smile: Emoji
`
</script>

<template>
  <MarkdownRender :content="markdownContent" />
</template>

Performance Features

The streaming-optimized engine delivers:

  • Incremental Parsing Code Blocks: Only processes changed content, not the entire code block
  • Efficient DOM Updates: Minimal re-renders
  • Monaco Streaming: Fast, incremental updates for large code snippets without blocking the UI
  • Progressive Mermaid: Diagrams render as soon as syntax is valid and refine as content streams in
  • Memory Optimized: Intelligent cleanup prevents memory leaks during long streaming sessions
  • Animation Frame Based: Smooth animations
  • Graceful Degradation: Handles malformed or incomplete Markdown without breaking

Props

Name Type Required Description
content string βœ“ Markdown string to render
nodes BaseNode[] Parsed markdown AST nodes (alternative to content)
customComponents Record<string, any> Custom Vue components for rendering

Either content or nodes must be provided.

Note: when using the component in a Vue template, camelCase prop names should be written in kebab-case. For example, customComponents becomes custom-components in templates.

Advanced

  • Custom Components: Pass your own components via customComponents prop to render custom tags inside markdown.

  • TypeScript: Full type support. Import types as needed:

    import type { MyMarkdownProps } from 'vue-renderer-markdown/dist/types'

Monaco Editor Integration

If you are using Monaco Editor in your project, configure vite-plugin-monaco-editor-esm to handle global injection of workers. Our renderer is optimized for streaming updates to large code blocksβ€”when content changes incrementally, only the necessary parts are updated for smooth, responsive rendering. On Windows, you may encounter issues during the build process. To resolve this, configure customDistPath to ensure successful packaging.

Note: If you only need to render a Monaco editor (for editing or previewing code) and don't require this library's full Markdown rendering pipeline, you can integrate Monaco directly using vue-use-monaco for a lighter, more direct integration.

Example Configuration

import path from 'node:path'
import monacoEditorPlugin from 'vite-plugin-monaco-editor-esm'

export default {
  plugins: [
    monacoEditorPlugin({
      languageWorkers: [
        'editorWorkerService',
        'typescript',
        'css',
        'html',
        'json',
      ],
      customDistPath(root, buildOutDir, base) {
        return path.resolve(buildOutDir, 'monacoeditorwork')
      },
    }),
  ],
}

This configuration ensures that Monaco Editor workers are correctly packaged and accessible in your project.

Mermaid: Progressive Rendering Example

Mermaid diagrams can be streamed progressively. The diagram renders as soon as the syntax becomes valid and refines as more content arrives.

<script setup lang="ts">
import { ref } from 'vue'
import MarkdownRender from 'vue-renderer-markdown'

const content = ref('')
const steps = [
  '```mermaid\n',
  'graph TD\n',
  'A[Start]-->B{Is valid?}\n',
  'B -- Yes --> C[Render]\n',
  'B -- No  --> D[Wait]\n',
  '```\n',
]

let i = 0
const id = setInterval(() => {
  content.value += steps[i] || ''
  i++
  if (i >= steps.length)
    clearInterval(id)
}, 120)
</script>

<template>
  <MarkdownRender :content="content" />
  <!-- Diagram progressively appears as content streams in -->
  <!-- Mermaid must be installed as a peer dependency -->
</template>

Thanks

This project is built with the help of these awesome libraries:

  • vue-use-monaco β€” Monaco Editor integration for Vue
  • shiki β€” Syntax highlighter powered by TextMate grammars and VS Code themes

Thanks to the authors and contributors of these projects!

Star History

Star History Chart

License

MIT Β© Simon He

For Tasks:

Click tags to check more tools for each tasks

For Jobs:

Alternative AI tools for vue-markdown-render

Similar Open Source Tools

For similar tasks

For similar jobs