Skip to main content
Registers custom or external diagram types to extend Mermaid’s built-in diagram support. This allows you to add new diagram syntaxes and renderers.

Signature

Parameters

ExternalDiagramDefinition[]
required
Array of external diagram definitions to register.
object
Configuration options for registration.

Return value

Promise<void> - Resolves when registration is complete (and diagrams are loaded if lazyLoad is false).

Examples

Basic external diagram registration

Registering multiple diagrams

Eager loading

Advanced detector with config

Complete diagram implementation example

Using with initialization

Usage notes

  • Must be called before attempting to render diagrams of the registered types
  • Detectors are checked in registration order
  • If multiple detectors match, the first registered one is used
  • With lazyLoad: true (default), diagram code is only loaded when first needed
  • With lazyLoad: false, all diagram implementations are loaded immediately
  • External diagrams have access to the same configuration system as built-in diagrams

Diagram definition structure

Your diagram loader must return an object with:
  • id: String identifier matching the registration
  • diagram: Object containing:
    • db: Database/state management object
    • renderer: Object with draw() method
    • parser: Object with parse() method
    • styles: Optional function returning CSS
    • init: Optional initialization function