Skip to content

feat: add mermaid diagram rendering with interactive viewer#349

Open
Benonii wants to merge 1 commit into
better-auth:mainfrom
Benonii:feat/mermaid-rendering
Open

feat: add mermaid diagram rendering with interactive viewer#349
Benonii wants to merge 1 commit into
better-auth:mainfrom
Benonii:feat/mermaid-rendering

Conversation

@Benonii

@Benonii Benonii commented May 7, 2026

Copy link
Copy Markdown

Problem

Mermaid diagrams in docs were not being recognized and rendered correctly with the current markdown-renderer component.

Fix

Install mermaid package, create a mermaid-diagram.tsx (a use client component) and use it to render mermaid diagrams when they are encountered.

changes

  • apps/web/package.json: added "mermaid": "^11.14.0"
  • apps/web/src/components/shared/highlighted-code-block.tsx: Changed one function to first check if lang is "mermaid" and return <MermaidDiagram> if that's the case. If not return old function.
  • apps/web/src/components/shared/markdown-renderer.tsx: Replace mermaid blocks with placeholder divs but save the code. After the HTML parser runs swap placeholder for real output. Also wraps the div containing HTML with <MermaidBlocks>
  • apps/web/src/components/shared/markdown-renderer.tsx: new file. Handles displaying mermaid diagrams inline and with an interactive viewer and copy, expand, pan and zoom buttons
  • bun.lock

Before:

Screenshot_20260507_031123

After:

image image

@vercel

vercel Bot commented May 7, 2026

Copy link
Copy Markdown

@Benonii is attempting to deploy a commit to the better-auth Team on Vercel.

A member of the Team first needs to authorize it.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant