Diagrammo in Nextra

Add the plugin, then write a diagram in any Markdown page.

Turbopack caveat: withDgmo injects remark-dgmo as a function-valued MDX option, which Turbopack can't serialize. Build with Webpack — run next build (Nextra 4's default) and next dev without --turbopack. If your scripts were scaffolded with that flag, drop it.

See it live — every chart type rendered through Nextra, refreshed on each release.

1.Install

bash
pnpm add nextra-dgmo @diagrammo/dgmo

Two small edits to your Nextra site. First, wire the remark plugin in next.config.mjs:

js
import nextra from 'nextra';
import { withDgmo } from 'nextra-dgmo/config';

const withNextra = nextra(
  withDgmo({}, { dgmo: { palette: 'slate' } })
);

export default withNextra({});

Then mount <DgmoClient /> in app/layout.tsx:

tsx
import './global.css';
import { DgmoClient } from 'nextra-dgmo/client';
import type { ReactNode } from 'react';

export default function RootLayout({ children }: { children: ReactNode }) {
  return (
    <html lang="en" suppressHydrationWarning>
      <body>
        {children}
        <DgmoClient />
      </body>
    </html>
  );
}

<DgmoClient /> is a no-render Client Component that re-runs viewBox tightening + copy buttons on every soft route change AND side-effect-imports the theme-aware nextra-dgmo/client.css (dark mode keyed on html.dark) — no manual @import needed.

2.Use

In any .md or .mdx file in your content tree

markdown
```dgmo
pie Browser Market Share (2025)
Chrome 63.5
Safari 19.8
Firefox  6.2
Edge     5.1
Other    5.4
```

Produces

Pie chart with 5 slices totalling 100; the largest is Chrome at 64%.Browser Market Share (2025)Chrome — 63.5 (64%)Safari — 19.8 (20%)Firefox — 6.2 (6%)Edge — 5.1 (5%)Other — 5.4 (5%)
pie Browser Market Share (2025)

Chrome           63.5
Safari           19.8
Firefox           6.2
Edge              5.1
Other             5.4

Nextra's theme switcher flips each diagram between its palette light and dark variants — no extra config. Every block is rendered twice at build time (light + dark SVG) and CSS hides the wrong one based on html.dark.

Everywhere else it goes

Keep the embedded diagram current

A live link shows the latest version wherever it is embedded, so editing the diagram once updates every place that holds it.