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

vitepress-mermaid-viewer

v0.4.0

Published

Mermaid diagrams for VitePress with interactive zoom, pan, and fullscreen viewing

Downloads

586

Readme

VitePress Mermaid Viewer

Diagrams that you can actually read.

npm version docs license

Mermaid diagrams for VitePress with interactive zoom, pan, and fullscreen viewing.

Features

  • Renders ```mermaid code blocks as diagrams
  • Click any diagram to open fullscreen viewer
  • Zoom: buttons, mouse wheel (cursor-centered), pinch-to-zoom (touch)
  • Pan/drag with mouse or touch
  • Keyboard accessible — Enter / Space to open, + / - / 0 / arrows inside the viewer, ARIA labels and focus management
  • Dark/light theme reactivity
  • Supports mmd alias for mermaid blocks
  • Per-page theme override via mermaidTheme frontmatter

Installation

npm install vitepress-mermaid-viewer mermaid

Quick Start

Simple setup with wrapper

// docs/.vitepress/config.ts
import { defineConfig } from 'vitepress';
import { withMermaid } from 'vitepress-mermaid-viewer';

export default withMermaid(
  defineConfig({
    // your VitePress config...

    // optional mermaid config
    mermaid: {
      theme: 'default',
    },

    // optional plugin config
    mermaidPlugin: {
      class: 'mermaid',
    },
  }),
);

Manual setup

// docs/.vitepress/config.ts
import { defineConfig } from 'vitepress';
import { MermaidPlugin, MermaidMarkdown } from 'vitepress-mermaid-viewer';

export default defineConfig({
  markdown: {
    config: (md) => {
      MermaidMarkdown(md, { class: 'mermaid' });
    },
  },

  vite: {
    plugins: [
      MermaidPlugin({
        // mermaid config
        theme: 'default',
      }),
    ],

    optimizeDeps: {
      include: ['@braintree/sanitize-url', 'dayjs', 'debug', 'cytoscape-cose-bilkent', 'cytoscape'],
    },

    resolve: {
      alias: {
        'dayjs/plugin/advancedFormat.js': 'dayjs/esm/plugin/advancedFormat',
        'dayjs/plugin/customParseFormat.js': 'dayjs/esm/plugin/customParseFormat',
        'dayjs/plugin/isoWeek.js': 'dayjs/esm/plugin/isoWeek',
        'cytoscape/dist/cytoscape.umd.js': 'cytoscape/dist/cytoscape.esm.js',
      },
    },
  },
});

Viewer Controls

| Action | Input | | ------------ | ---------------------------------------------------- | | Open viewer | Click on diagram, Enter / Space when focused | | Zoom in | + button, mouse wheel up, pinch out, + / = key | | Zoom out | button, mouse wheel down, pinch in, - key | | Pan | Click and drag, arrow keys | | Reset | button, 0 key | | Download SVG | SVG button in viewer | | Download PNG | PNG button in viewer | | Close | button, Escape key |

Frontmatter Options

Override mermaid theme per page:

---
mermaidTheme: forest
---

API

withMermaid(config: UserConfig): UserConfig

Wraps VitePress config — adds markdown plugin, Vite plugin, optimizeDeps, and module aliases.

MermaidMarkdown(md, options?)

Markdown-it plugin. Intercepts ```mermaid fences and renders them as <Mermaid> components.

Options:

  • class — CSS class for diagram container (default: 'mermaid')

MermaidPlugin(config?)

Vite plugin. Injects <Mermaid> component globally and serves mermaid config via virtual module.

Accepts mermaid configuration object.

Additional options:

  • download — show Download SVG button in viewer (default: true)
  • downloadPng — show Download PNG button in viewer (default: true)

Contributing

Contributions are welcome! See CONTRIBUTING.md for guidelines.

License

MIT