<?xml version="1.0" encoding="UTF-8"?><rss xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:atom="http://www.w3.org/2005/Atom" version="2.0" xmlns:cc="http://cyber.law.harvard.edu/rss/creativeCommonsRssModule.html">
    <channel>
        <title><![CDATA[Stories by JointJS on Medium]]></title>
        <description><![CDATA[Stories by JointJS on Medium]]></description>
        <link>https://medium.com/@jointjs?source=rss-04b9828fb6b2------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/1*TECzsKXcb7ZCFCFglFoanA.png</url>
            <title>Stories by JointJS on Medium</title>
            <link>https://medium.com/@jointjs?source=rss-04b9828fb6b2------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Fri, 20 Nov 2026 22:54:27 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@jointjs/feed" rel="self" type="application/rss+xml"/>
        <webMaster><![CDATA[yourfriends@medium.com]]></webMaster>
        <atom:link href="http://medium.superfeedr.com/" rel="hub"/>
        <item>
            <title><![CDATA[JointJS for React: Key differences that change how you build]]></title>
            <link>https://medium.com/diagramming-for-developers/jointjs-for-react-key-differences-that-change-how-you-build-aff6b7b471fb?source=rss-04b9828fb6b2------2</link>
            <guid isPermaLink="false">https://medium.com/p/aff6b7b471fb</guid>
            <category><![CDATA[web-development]]></category>
            <category><![CDATA[diagramming-tools]]></category>
            <category><![CDATA[react]]></category>
            <category><![CDATA[diagramming]]></category>
            <category><![CDATA[workflow-automation]]></category>
            <dc:creator><![CDATA[JointJS]]></dc:creator>
            <pubDate>Thu, 19 Nov 2026 12:38:43 GMT</pubDate>
            <atom:updated>2026-11-19T12:39:33.619Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*ZccqeFRtXcJtNzAK.jpg" /></figure><p>JointJS for React (<a href="https://www.npmjs.com/package/@joint/react">@joint/react</a>) is a native React integration for JointJS. It makes adding production-grade diagrams to React applications much easier.</p><p>If you’ve embedded JointJS into a React app before, you already know that you have to jump through hoops with a useEffect wrapper, create a graph and paper imperatively, attach and remove event listeners by hand, and keep React state in sync through custom bridge code. It works, but it’s not elegant, and it’s not how you’d expect it to work in the React ecosystem.</p><p>JointJS for React fixes all of that and makes JointJS work with React natively. Diagram cells become React-readable state, nodes are plain React components, and setup, cleanup, events, and data flow follow familiar React patterns.</p><p>In this guide, you’ll see eight common integration patterns side by side, with code examples showing how you’d handle each one before, by integrating JointJS into React manually, and how you handle it now with the native JointJS for React integration.</p><blockquote><strong>Note about JointJS and JointJS for React</strong></blockquote><blockquote>JointJS for React is a native React integration for JointJS. The JointJS core library is still actively developed, it’s used by JointJS for React, and it’s the right choice for vanilla JavaScript and other frameworks.</blockquote><blockquote>The <a href="https://www.npmjs.com/package/@joint/core">@joint/core</a> is deliberately low-level, so you can configure everything through its API. JointJS for React adds a layer of convenience on top with related options combined into single choices, sensible defaults, callbacks that receive named values instead of positional arguments, and styling that looks great out of the box.</blockquote><p>In<a href="https://www.jointjs.com/blog/introducing-jointjs-for-react"> Introducing JointJS for React</a>, we compared a basic <em>Hello World</em> setup before and after. This guide goes further and covers what changes across a real component: state, rendering, events, sizing, data flow, and types.</p><h3>1. Basic diagram setup</h3><p>With a manual integration, you have to repeat the same lifecycle code in every component that hosts a diagram, from refs for the graph and the paper, auseEffect that constructs them against a DOM node, to a cleanup callback.</p><p><strong>Before: manual integration</strong></p><pre>// DO NOT USE - Old way of integrating JointJS with React<br><br>import { useEffect, useRef } from &#39;react&#39;;<br>import { dia, shapes } from &#39;@joint/core&#39;;<br><br>const cellNamespace = shapes;<br><br>function Diagram() {<br>  const containerRef = useRef &lt;HTMLDivElement&gt; null;<br><br>  // Kept in refs so handlers, other effects, and child components can reach them<br>  const graphRef = (useRef &lt;dia.Graph) | (null&gt; null);<br>  const paperRef = (useRef &lt;dia.Paper) | (null&gt; null);<br><br>  useEffect(() =&gt; {<br>    const container = containerRef.current;<br>    if (!container) return;<br><br>    const graph = new dia.Graph({}, { cellNamespace });<br>    const paper = new dia.Paper({<br>      model: graph,<br>      cellViewNamespace: cellNamespace,<br>    });<br><br>    // Append instead of passing `el`, so paper.remove()<br>    // doesn&#39;t remove the React-owned &lt;div&gt; from the DOM<br>    container.appendChild(paper.el);<br><br>    graphRef.current = graph;<br>    paperRef.current = paper;<br><br>    return () =&gt; {<br>      paper.remove();<br>      graphRef.current = null;<br>      paperRef.current = null;<br>    };<br>  }, []);<br><br>  return &lt;div ref={containerRef} /&gt;;<br>}</pre><p>In production-grade apps, this setup usually evolves into a custom context provider that exposes the graph and paper to the rest of the tree, which is exactly what GraphProvider gives you.</p><p><strong>After: JointJS for React</strong></p><pre>// New native JointJS for React integration<br><br>import { GraphProvider, Paper } from &#39;@joint/react&#39;;<br><br>function Diagram() {<br>  return (<br>    &lt;GraphProvider&gt;<br>      &lt;Paper style={{ width: &#39;100%&#39;, height: &#39;100%&#39; }} /&gt;<br>    &lt;/GraphProvider&gt;<br>  );<br>}</pre><p>&lt;GraphProvider&gt; and &lt;Paper&gt; manage the lifecycle, and cleanup happens automatically when they unmount. There are no refs to manage and no mount effect to get wrong under double useEffect calls in React Strict Mode.</p><p>You also don’t need a cellNamespace unless you register custom shapes, because the provider already includes the built-in ones, and you can size &lt;Paper&gt; with CSS instead of using width and height options.</p><h3>2. Reading diagram state</h3><p>Before, reading a value out of the diagram meant subscribing to graph events inside a useEffect, filtering for the change you care about, and calling setState.</p><p><strong>Before: manual integration</strong></p><pre>// DO NOT USE - Old way of integrating JointJS with React<br><br>const [label, setLabel] = useState(&#39;&#39;);<br><br>useEffect(() =&gt; {<br>  const graph = graphRef.current;<br>  if (!graph) return;<br><br>  // Read the initial value, or the label stays empty until the first change<br>  setLabel(graph.getCell(id)?.attr(&#39;label/text&#39;) ?? &#39;&#39;);<br><br>  const handler = (cell: dia.Cell) =&gt; {<br>    if (cell.id === id) setLabel(cell.attr(&#39;label/text&#39;));<br>  };<br>  graph.on(&#39;change:attrs&#39;, handler);<br>  return () =&gt; {<br>    graph.off(&#39;change:attrs&#39;, handler);<br>  };<br>}, [id]);</pre><p><strong>After: JointJS for React</strong></p><pre>// New JointJS for React native integration<br><br>const { label } = useCell(id, selectElementData);<br><br>const count = useCells((cells) =&gt; cells.length);</pre><p>The manual version is convoluted, complex, and has plenty of pieces that can go wrong. You need to pick up the right event ( change:attrs, not the catch-all change), write the id filter, and remember to read the initial value.</p><p>In JointJS for React, useCell and useCells return the current value on the first render and re-render only when the selected slice changes, so dragging a node never re-renders a component that only reads labels, and there&#39;s no event name to get right.</p><p>The library provides selectors you can use to access state: selectElementPosition, selectElementSize, selectElementAngle, selectElementData, and selectCellType.</p><p>If you need raw JointJS events anyway, you can use useOnGraphEvents to listen for native events, such as add, remove, or change:position.</p><h3>3. Rendering nodes as React components</h3><p>Before JointJS for React, a node’s appearance lived in a model class with SVG markup, attrs, and presentation logic in defaults(). It&#39;s a powerful system, but in a React app it meant switching mental models, as CSS animations, a charting library inside a node, or content driven by app state all needed workarounds.</p><p><strong>Before: manual integration</strong></p><pre>// DO NOT USE - Old way of integrating JointJS with React<br><br>class Node extends dia.Element {<br>  defaults() {<br>    return {<br>      ...super.defaults,<br>      type: &#39;Node&#39;,<br>      size: { width: 160, height: 60 },<br>      attrs: {<br>        body: { width: &#39;calc(w)&#39;, height: &#39;calc(h)&#39;, fill: &#39;#1B2538&#39;, stroke: &#39;#4D9FFF&#39;, rx: 6 },<br>        label: {<br>          x: &#39;calc(0.5*w)&#39;,<br>          y: &#39;calc(0.5*h)&#39;,<br>          text: &#39;&#39;,<br>          fill: &#39;#CAD3E5&#39;,<br>          textVerticalAnchor: &#39;middle&#39;,<br>          textAnchor: &#39;middle&#39;,<br>        },<br>      },<br>      markup: [<br>        { tagName: &#39;rect&#39;, selector: &#39;body&#39; },<br>        { tagName: &#39;text&#39;, selector: &#39;label&#39; },<br>      ],<br>    };<br>  }<br>}<br><br>// Register the shape so the graph and paper can resolve type: &#39;Node&#39;<br>const cellNamespace = { ...shapes, Node };</pre><p><strong>After: JointJS for React</strong></p><pre>// New native JointJS for React integration<br><br>&lt;Paper<br>  renderElement={({ label, status }) =&gt; (<br>    &lt;HTMLHost&gt;<br>      &lt;div className={`node node--${status}`}&gt;{label}&lt;/div&gt;<br>    &lt;/HTMLHost&gt;<br>  )}<br>/&gt;</pre><p>The renderElement prop accepts a plain React component, so you can use any hook, library, or stylesheet you&#39;d use anywhere else in your app.</p><p>You also don’t need to hand-roll a foreignObject. HTMLHost renders the element as a &lt;div&gt; that sizes itself to its content and syncs the measured size back to the graph automatically. Because it sets its own width and height inline, style and size the content you put inside it rather than the host itself.</p><p>HTMLBox does the same with a default theme driven by --jj-box-* CSS variables; import @joint/react/styles.css and your nodes look right before you write any CSS.</p><h3>4. Handling paper events without stale closures</h3><p>Before JointJS for React, setting up a paper listener in a component created the classic stale closure problem, so you had to re-subscribe on every change or maintain a ref by hand.</p><p><strong>Before: manual integration</strong></p><pre>// DO NOT USE - Old way of integrating JointJS with React<br><br>// Keep the latest handler in a ref<br>const onSelectRef = useRef(onSelect);<br>useEffect(() =&gt; {<br>  onSelectRef.current = onSelect;<br>}, [onSelect]);<br><br>useEffect(() =&gt; {<br>  // Capture the paper locally<br>  const paper = paperRef.current;<br>  if (!paper) return;<br><br>  const handler = (view: dia.ElementView) =&gt; onSelectRef.current(view.model.id);<br>  paper.on(&#39;element:pointerclick&#39;, handler);<br>  return () =&gt; {<br>    paper.off(&#39;element:pointerclick&#39;, handler);<br>  };<br>}, []);</pre><p>‍ <strong>After: JointJS for React</strong></p><pre>// New native JointJS for React integration<br><br>&lt;Paper onElementPointerClick={({ id }) =&gt; onSelect(id)} /&gt;</pre><p>You only need to set up a prop on paper, precisely as it should be. The paper subscribes once and reads the current handler on every event, so you can use inline arrow functions, and you don’t need to wrap the parent’s handler in useCallback.</p><p>You can also listen for paper events outside &lt;Paper&gt; with the useOnPaperEvents hook:</p><pre>// New JointJS for React native integration<br><br>useOnPaperEvents({<br>  onElementPointerClick: ({ id }) =&gt; onSelect(id),<br>});</pre><p>Handlers like onElementPointerClick get a single params object with named properties, instead of native JointJS event names with positional arguments. If you prefer JointJS core event names and arguments, such as element:pointerclick, you can use those in the same hook.</p><h3>5. Auto-sizing nodes from measured content</h3><p>Before, a node that sized itself to HTML content meant writing a custom element view where you had to observe the HTML inside a foreignObject, write its size back to the model, and disconnect the observer when the view is removed.</p><p><strong>Before: manual integration</strong></p><pre>// DO NOT USE - Old way of integrating JointJS with React<br><br>// The Card model&#39;s markup (not shown) has a &lt;foreignObject&gt; with a &#39;content&#39; &lt;div&gt;<br>class CardView extends dia.ElementView {<br>  private observer: ResizeObserver | null = null;<br><br>  render() {<br>    super.render();<br>    this.observer?.disconnect();<br>    const content = this.findNode(&#39;content&#39;) as HTMLElement;<br>    this.observer = new ResizeObserver(([entry]) =&gt; {<br>      const [box] = entry.borderBoxSize;<br>      this.model.resize(Math.ceil(box.inlineSize), Math.ceil(box.blockSize));<br>    });<br>    this.observer.observe(content);<br>    return this;<br>  }<br><br>  onRemove() {<br>    this.observer?.disconnect();<br>    super.onRemove();<br>  }<br>}<br><br>const cellNamespace = { ...shapes, Card, CardView };</pre><p><strong>After: JointJS for React</strong></p><pre>// New native JointJS for React integration<br><br>&lt;Paper<br>  renderElement={({ title }) =&gt; (<br>    &lt;HTMLHost&gt;<br>      &lt;div className=&quot;card&quot;&gt;{title}&lt;/div&gt;<br>    &lt;/HTMLHost&gt;<br>  )}<br>/&gt;</pre><p>HTMLHost measures its content, writes the size to the model, and cleans up with the element, so there&#39;s nothing to manage.</p><p>If you need your own markup around the HTML, such as an SVG shape behind it, you can use the useMeasureElement hook.</p><p>You can find more details about useMeasureElement in the <a href="https://docs.jointjs.com/api-react/Hooks/useMeasureElement/">JointJS docs</a>, and you can also check the <a href="https://react.jointjs.com/learn/?path=/docs/examples-resizable-node--docs&amp;globals=backgrounds.grid:!true">Resizable Node Example demo</a>.</p><h3>6. Syncing graph state with React</h3><p>Before, the graph owned its cell data, so to connect a diagram state to Redux or a parent useState you needed to listen for mutation events by hand, design the bridge and its contract yourself.</p><p><strong>Before: manual integration</strong></p><pre>// DO NOT USE - Old way of integrating JointJS with React<br><br>const [cells, setCells] = useState&lt;dia.Cell.JSON[]&gt;(initialCells);<br>const fromGraphRef = useRef&lt;dia.Cell.JSON[] | null&gt;(null);<br>const applyingRef = useRef(false);<br><br>// Graph -&gt; React<br>useEffect(() =&gt; {<br> const graph = graphRef.current;<br> if (!graph) return;<br> const sync = () =&gt; {<br>   if (applyingRef.current) return; // ignore our own writes<br>   const next = graph.toJSON().cells;<br>   fromGraphRef.current = next;<br>   setCells(next);<br> };<br> graph.on(&#39;add remove change reset&#39;, sync);<br> return () =&gt; { graph.off(&#39;add remove change reset&#39;, sync); };<br>}, []);<br><br>// React -&gt; Graph<br>useEffect(() =&gt; {<br> const graph = graphRef.current;<br> if (!graph || cells === fromGraphRef.current) return; // change came from the graph<br> applyingRef.current = true;<br> graph.resetCells(cells); // rebuilds every view<br> applyingRef.current = false;<br>}, [cells]);</pre><p><strong>After: JointJS for React</strong></p><p>There are three modes, and each one is a prop.</p><p><strong>Uncontrolled:</strong> JointJS owns the data after mount.</p><pre>// New native JointJS for React integration<br><br>&lt;GraphProvider initialCells={initialCells}&gt;<br>  &lt;Paper /&gt;<br>&lt;/GraphProvider&gt;</pre><p><strong>Controlled:</strong> React drives the cells array, just like &lt;input value&gt;.</p><pre>// New native JointJS for React integration<br><br>const [cells, setCells] = useState(initialCells);<br><br>&lt;GraphProvider cells={cells} onCellsChange={setCells}&gt;<br>  &lt;Paper /&gt;<br>&lt;/GraphProvider&gt;</pre><p><strong>Incremental:</strong> granular deltas per commit, ready for an external store.</p><pre>// New native JointJS for React integration<br><br>&lt;GraphProvider<br>  initialCells={initialCells}<br>  onIncrementalCellsChange={({ added, changed, removed }) =&gt;<br>    store.apply({ added, changed, removed })<br>  }<br>&gt;<br>  &lt;Paper /&gt;<br>&lt;/GraphProvider&gt;</pre><h3>7. Changing the graph from anywhere with useGraph()</h3><p>Before, renaming a node from a toolbar, sidebar, or command palette meant passing graphRef.current down through props or building your own context around a ref.</p><p>‍ <strong>Before: manual integration</strong></p><pre>// DO NOT USE - Old way of integrating JointJS with React<br><br>// graphRef is created next to the paper and passed down via every layer in between<br>function Toolbar({ graphRef, selectedId }: { graphRef: RefObject&lt;dia.Graph | null&gt;; selectedId: dia.Cell.ID }) {<br> const rename = (id: dia.Cell.ID, text: string) =&gt; {<br>   graphRef.current?.getCell(id)?.attr(&#39;label/text&#39;, text);<br> };<br> return &lt;button onClick={() =&gt; rename(selectedId, &#39;New name&#39;)}&gt;Rename&lt;/button&gt;;<br>}</pre><p><strong>After: JointJS for React</strong></p><pre>// New native JointJS for React integration<br><br>// Any descendant of &lt;GraphProvider&gt;, no graph prop needed<br>function Toolbar({ selectedId }: { selectedId: string }) {<br> const { setCellData } = useGraph();<br> return (<br>   &lt;button onClick={() =&gt; setCellData(selectedId, (prev) =&gt; ({ ...prev, label: &#39;New name&#39; }))}&gt;<br>     Rename<br>   &lt;/button&gt;<br> );<br>}</pre><p>Any descendant of &lt;GraphProvider&gt; can reach the graph, with no props threaded through layout components. What you get back is a typed API:</p><ul><li>setCell / setCellData - Add or update a cell, or only its data</li><li>removeCell / removeCells - Remove cells by id or reference</li><li>resetCells / updateCells - Replace or transform the whole set</li><li>exportToJSON / importFromJSON - Serialize and restore the graph</li><li>isElement / isLink - Type guards backed by the graph’s type registry</li><li>transaction - Group many edits into one undo entry and one render</li><li>graph - The underlying dia.Graph, when you need it</li></ul><h3>A simple JointJS for React diagram</h3><p>Here’s a small but complete diagram that combines several of these patterns: two nodes, a link, React-rendered nodes, click-to-select, and a button that renames a node from outside the canvas.</p><pre>// New native JointJS for React integration<br><br>import { GraphProvider, Paper, HTMLBox, useGraph } from &#39;@joint/react&#39;;<br>import &#39;@joint/react/styles.css&#39;;<br><br>const initialCells = [<br> { id: &#39;a&#39;, type: &#39;element&#39;, position: { x: 40, y: 40 }, data: { label: &#39;Start&#39; } },<br> { id: &#39;b&#39;, type: &#39;element&#39;, position: { x: 280, y: 180 }, data: { label: &#39;End&#39; } },<br> { id: &#39;ab&#39;, type: &#39;link&#39;, source: { id: &#39;a&#39; }, target: { id: &#39;b&#39; } },<br>];<br><br>function RenameButton() {<br> const { setCellData } = useGraph();<br> return (<br>   &lt;button onClick={() =&gt; setCellData(&#39;a&#39;, (prev) =&gt; ({ ...prev, label: &#39;Renamed&#39; }))}&gt;<br>     Rename<br>   &lt;/button&gt;<br> );<br>}<br><br>export default function Diagram({ onSelect }: { onSelect: (id: string) =&gt; void }) {<br> return (<br>   &lt;GraphProvider initialCells={initialCells}&gt;<br>     &lt;Paper<br>       style={{ width: &#39;100%&#39;, height: &#39;100%&#39; }}<br>       renderElement={({ label }) =&gt; &lt;HTMLBox&gt;{label}&lt;/HTMLBox&gt;}<br>       onElementPointerClick={({ id }) =&gt; onSelect(String(id))}<br>     /&gt;<br>     &lt;RenameButton /&gt;<br>   &lt;/GraphProvider&gt;<br> );<br>}</pre><p>There are no refs, effects, teardown calls, or model subclasses. Everything you needed to set up before, from lifecycle and event wiring to measurement and sync, is handled by the graph provider, the paper, and the hooks.</p><h3>Transition to JointJS for React gradually</h3><p>You don’t have to rewrite your whole app to try JointJS for React. It’s an integration that uses <a href="https://www.npmjs.com/package/@joint/core">@joint/core</a> and exposes it, so links, routers, connectors, ports, tools, and the paper transform model all work as before.</p><p>To use a pre-existing JointJS graph instance, use the graph prop (&lt;GraphProvider graph={existingGraph}&gt;), and you can use useGraph().graph to access the underlying dia.Graph whenever you need the core API. That way, you can start transitioning your app gradually instead of rewriting everything at once.</p><h3>Conclusion</h3><p>Everything outlined in this guide was already possible if you manually wrote it by hand, but with JointJS for React, it’s simpler, much more elegant, and at the end of the day, it’s a lot less code to write and maintain.</p><p>To quickly get up to speed with JointJS for React, check one of the following resources:</p><ul><li><a href="https://www.jointjs.com/blog/how-to-get-started-with-jointjs-for-react">Short guide on the easiest ways to get started with JointJS for React</a></li><li><a href="https://docs.jointjs.com/react/getting-started/">JointJS for React Quickstart guide in the official docs</a></li><li><a href="https://www.jointjs.com/free-trial">Start a free trial of JointJS+ for React</a>‍</li></ul><h3>FAQ</h3><h4>Is core JointJS deprecated now that JointJS for React exists?</h4><p>No. Core JointJS is actively developed and powers JointJS for React under the hood. It remains the right choice for vanilla JavaScript and for Angular, Vue, and Svelte projects.</p><h4>What boilerplate does JointJS for React remove?</h4><p>All integration code you would otherwise have to write by hand, from refs for the graph and paper, mount effects and teardown, event-listener wiring, to stale-closure workarounds.</p><h4>Do I have to fully rewrite existing diagrams to use JointJS for React?</h4><p>No. You can use JointJS graph instance you already have (&lt;GraphProvider graph={existingGraph}&gt;), and you can also access the underlying dia.Graph whenever you need the core API with useGraph().graph. This allows you to migrate your app to JointJS for React one component at a time.</p><h4>Can I keep diagram state in Redux, Zustand, or useState?</h4><p>Yes. Simply pass the cells and onCellsChange props for fully controlled state, or use onIncrementalCellsChange to receive added, changed, and removed deltas for your store.</p><p><em>Originally published at </em><a href="https://www.jointjs.com/blog/jointjs-for-react-key-differences-that-change-how-you-build-production-grade-diagrams"><em>https://www.jointjs.com</em></a><em>.</em></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=aff6b7b471fb" width="1" height="1" alt=""><hr><p><a href="https://medium.com/diagramming-for-developers/jointjs-for-react-key-differences-that-change-how-you-build-aff6b7b471fb">JointJS for React: Key differences that change how you build</a> was originally published in <a href="https://medium.com/diagramming-for-developers">Diagramming for Developers</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[How to embed a visual Mermaid editor in your React app]]></title>
            <link>https://medium.com/diagramming-for-developers/how-to-embed-a-visual-mermaid-editor-in-your-react-app-cc898c0e499e?source=rss-04b9828fb6b2------2</link>
            <guid isPermaLink="false">https://medium.com/p/cc898c0e499e</guid>
            <category><![CDATA[software-development]]></category>
            <category><![CDATA[diagramming-tools]]></category>
            <category><![CDATA[mermaid]]></category>
            <category><![CDATA[diagramming]]></category>
            <dc:creator><![CDATA[JointJS]]></dc:creator>
            <pubDate>Wed, 04 Nov 2026 13:04:01 GMT</pubDate>
            <atom:updated>2026-11-04T13:04:01.617Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="An example diagram with title Mermaid Editor, and the Mermaid logo." src="https://cdn-images-1.medium.com/max/1000/1*T8_xPUcpVQMnuTkYk8tDXQ.png" /></figure><p>Mermaid has effectively become the standard for diagrams as code. You write a flowchart like A --&gt; B in Markdown, GitHub renders it, and it lives in version control next to your code. Mermaid diagrams are in READMEs, docs sites, and wikis, and increasingly the output across almost all major AI platforms for generating text-based diagrams. All of this makes Mermaid the obvious format for any product that displays diagrams, and the next step for those products is a visual Mermaid editor that lets users change a diagram by clicking on it instead of learning the syntax.</p><iframe src="https://cdn.embedly.com/widgets/media.html?src=https%3A%2F%2Fwww.youtube.com%2Fembed%2FNyQq2KX3O6U%3Ffeature%3Doembed&amp;display_name=YouTube&amp;url=https%3A%2F%2Fwww.youtube.com%2Fwatch%3Fv%3DNyQq2KX3O6U&amp;image=https%3A%2F%2Fi.ytimg.com%2Fvi%2FNyQq2KX3O6U%2Fhqdefault.jpg&amp;type=text%2Fhtml&amp;schema=youtube" width="854" height="480" frameborder="0" scrolling="no"><a href="https://medium.com/media/d8504cd88f6470ffd8afa364d8215076/href">https://medium.com/media/d8504cd88f6470ffd8afa364d8215076/href</a></iframe><p>But Mermaid diagrams integrated into products can quickly show their limits. The output is a static SVG; users can’t click a node to rename it or restyle an arrow without learning the syntax. Just as well, a typical visual editor built on top keeps its own copy of the diagram, separate from the Mermaid text. When you edit the diagram, the text becomes out of date. If you edit the text, the diagram is no longer accurate. Teams building docs platforms, wikis, low-code tools, and AI assistants often realize that Mermaid is great, but the editing experience isn’t.</p><p>To close that gap, we built the Mermaid Editor app template with JointJS, a diagramming library for building visual editors in JavaScript and React. It reads Mermaid with Mermaid’s own parser, renders it as a live, editable diagram, and writes every canvas change back into the text.</p><p>In this article, you’ll see what the JointJS Mermaid Editor does, the patterns behind it, and how to embed it in your own React app.</p><h3>About the JointJS Mermaid Editor demo</h3><p><a href="https://jointjs.com/demos/mermaid-editor">The Mermaid Editor</a> is a split-screen editor for Mermaid flowcharts. You write Mermaid on the left, and on the right you get a real, interactive diagram rendered by JointJS+ for React. As you type, the source is reparsed, and the diagram is laid out as you go. When you edit the diagram, the text changes.</p><iframe src="https://cdn.embedly.com/widgets/media.html?src=https%3A%2F%2Fplayer.vimeo.com%2Fvideo%2F1242448332%3Fapp_id%3D122963&amp;dntp=1&amp;display_name=Vimeo&amp;url=https%3A%2F%2Fvimeo.com%2F1242448332&amp;image=https%3A%2F%2Fi.vimeocdn.com%2Fvideo%2F2220699037-7335d79504f15c7834a31dd95ad10a04bb5f16dbfc8f45f2990b6b4c4a24c285-d_1280%3Fregion%3Dus&amp;type=text%2Fhtml&amp;schema=vimeo" width="1920" height="1422" frameborder="0" scrolling="no"><a href="https://medium.com/media/058d46ca981ef675307a4c9958694c36/href">https://medium.com/media/058d46ca981ef675307a4c9958694c36/href</a></iframe><p>Here’s what that looks like in practice:</p><ul><li><strong>It works with standard Mermaid syntax.</strong> All classic delimiter shapes ([ ], ( ), { }, [( )], and the rest), the extended v11 @{ shape: ... } catalog, @{ img: ... } image nodes, nested subgraph blocks, style, classDef, click links, linkStyle, edge labels, curves, and even @{ animate: true } dash animated links.</li><li><strong>Every node is a real SVG shape that sizes itself to its label.</strong> No fixed-width boxes with overflowing text.</li><li><strong>The source and the canvas point at each other.</strong> Click a node, and every mention of it lights up in the source. Move the caret in the editor, and the diagram selects and scrolls to the node you’re on.</li><li><strong>The canvas is an editor, not a viewer.</strong> Double-click to rename a node in place. Select a node to see a toolbar with shape, fill, text color, bold and italic, border, hyperlink, image, and an “add a step” action. Select a link to change its line pattern, arrowheads, color, curve, and animation. Shift-click to select two nodes, and the editor offers to connect them.</li><li><strong>Every edit is written into the Mermaid text.</strong> The source stays the single source of truth, so what you export is still a plain .mmd file that works in GitHub, GitLab, Notion, or anywhere else Mermaid does.</li><li><strong>It’s a proper canvas.</strong> Pan and zoom on an infinite PaperScroller, switch layout direction and link routing (curved or orthogonal), toggle light and dark themes, and export the diagram to SVG.</li></ul><p>The source editor is Monaco, the same editor that powers VS Code, with Mermaid syntax highlighting, autocompletion, find and replace, multiple cursors, and full undo history.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*Pl0BMUpQyuMJq9X1.png" /><figcaption>A detail from the Mermaid Editor, a node toolbar.</figcaption></figure><p>You can find the full source code on GitHub:<a href="https://github.com/clientIO/joint-demos/tree/main/mermaid-editor"> clientIO/joint-demos/mermaid-editor</a>.</p><h3>How the editor keeps the Mermaid text and the diagram in sync</h3><p>The key aspect of the Mermaid Editor, precisely as in our<a href="https://www.jointjs.com/demos/data-modeling"> Data Modeling App Template</a>, is that there is a single source of truth, the Mermaid text.</p><p>The visual diagram is never edited directly, but rather always a rendering of the current source. When you type, the source changes and the diagram is rendered from it. When you change something on the canvas, the app doesn’t touch the diagram, but computes the new Mermaid text and derives the visual from that.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*_FgWEBLKlNM1g0F_.png" /><figcaption><em>Every first edit updates the Mermaid text, and then renders the diagram from it.</em></figcaption></figure><p>Everything flows clockwise. The text will be parsed by Mermaid, mapped to JointJS cells, and rendered. Canvas actions become text edits, which start the loop again. There’s no second model to keep in sync, so the diagram and the text can’t fall out of sync.</p><p>An automatic layout engine calculates node positions on every render, just as Mermaid does. The editor supports the two layout engines Mermaid offers for flowcharts. Dagre, a layered layout with smooth, curved links, which is the default, and ELK, which routes links at right angles and is used when the source sets layout: elk. You can easily switch between them by editing Mermaid text.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*wAeQbTVj6MRs5K5f.png" /><figcaption><em>A look at the layout: elk option in Mermaid config.</em></figcaption></figure><h3>From Mermaid to JointJS cells</h3><p>Mermaid’s syntax is large, evolving, and full of edge cases, so the demo uses Mermaid’s own parser and reads the result from its diagram database:</p><pre>// src/mermaid/parse.ts<br><br>const mermaid = await loadMermaid();<br><br>let diagram;<br>try {<br>  diagram = await mermaid.mermaidAPI.getDiagramFromText(text);<br>} catch (error) {<br>  throw new MermaidParseError(toMessage(error));<br>}<br><br>// … (rejects diagram types other than flowchart)<br><br>const db = diagram.db as unknown as FlowDbLike;<br>const { nodes, edges } = db.getData();</pre><p>When Mermaid is parsed, it figures out what each shape should be, breaks two-way arrows into separate one-way arrows, and keeps track of which nodes are inside each subgraph.</p><p>The parsed graph is then mapped onto declarative JointJS cell records with a single pure function:</p><pre>// src/mermaid/to-cells.ts<br><br>export function toCells(flow: FlowGraph): MermaidCell[]</pre><p>That’s the same pattern the<a href="https://www.jointjs.com/blog/how-to-build-production-grade-data-modeling-apps-in-react-a-jointjs-architecture-walkthrough"> Data Modeling app</a> uses with schemaToCells.</p><h4>Nodes grow to fit their labels</h4><p>Each node on the diagram is a React component that renders its Mermaid shape as SVG, and useMeasureElement measures the label and provides its exact sizing:</p><pre>// src/components/render-node.tsx<br><br>const { width, height } = useMeasureElement(textRef, options);</pre><p>That’s why a diamond with a long label grows bigger instead of clipping its text, and why a label can span as many lines as it needs to. Shapes are defined once in shapes.ts, and the same geometry draws both the node on the canvas and its icon in the toolbar&#39;s shape picker, so the two can never drift apart.</p><h4>Subgraphs become real containers</h4><p>A Mermaid subgraph turns into a JointJS container element. Its nodes are embedded inside it, and after layout, the container is resized to fit perfectly. Because the nodes really belong to the container, rather than sitting on a box drawn behind them, subgraphs can be nested too.</p><h4>Links keep their Mermaid styling</h4><p>Each Mermaid link (the parser returns them as edges) becomes a JointJS link that carries everything Mermaid knows about it, from solid, dotted, or thick lines, to point, circle, or cross arrowheads at either end, labels, linkStyle colors and widths, curved routing for Mermaid&#39;s curve families, and a CSS marching-dash animation for animate: true links.</p><h4>Layout runs when every node is measured</h4><p>Once every node is measured, DirectedGraph.layout from <a href="https://docs.jointjs.com/learn/features/automatic-layouts/directed-graph/">@joint/layout-directed-graph</a> arranges the graph in whatever direction the source declares ( TB, BT, LR, or RL). The DirectedGraph.layout is the default, the same dagre-style layout Mermaid uses, with curved links. When you set layout: elk option, the editor switches to <a href="https://docs.jointjs.com/learn/features/automatic-layouts/elk">@joint/layout-elk</a> with orthogonal links.</p><pre>useOnElementsMeasured(({ graph: measuredGraph }) =&gt; {<br>    settle(measuredGraph, onLayoutSettled);<br>});</pre><p>The useOnElementsMeasured hook repaints the paper right after the callback, so there&#39;s never a frame where diagram nodes are visible at their pre-layout position.</p><h3>From the diagram canvas back to Mermaid</h3><p>Rendering Mermaid is the easier half. The hard part, and the reason so many Mermaid tools stop at a preview, is writing visual edits back into Mermaid format without breaking it.</p><p>The obvious approach is to regenerate the whole source from the parsed graph after every edit. It’s also the wrong one. Mermaid’s parsed output is a normalization, not a faithful syntax tree, so it has no comments, no formatting, no classDef names, and shapes come back as IDs rather than the delimiters the author typed. With this approach, every click on the canvas would reformat the author&#39;s entire document, delete their comments, and produce a massive diff.</p><p>In this app, the source is never fully recreated. Every canvas action is a targeted edit that finds the exact span of text responsible for the change made and splices in the new value.</p><p>For example, here’s how renaming a node works:</p><pre>// src/mermaid/edit-source.ts<br><br>export function setNodeLabel(source: string, id: CellId, label: string): string | null {<br>   // … (a v11 `id@{ label: … }` block is edited in place first)<br><br>   const parsed = parse(source);<br>   const declaration = findDeclaration(parsed, id);<br>   if (!declaration) return null;<br>   const text = quoteLabel(encodeBreaks(label.trim()));<br><br>   if (declaration.labelFrom !== undefined &amp;&amp; declaration.labelTo !== undefined) {<br>       return splice(source, declaration.labelFrom, declaration.labelTo, text);<br>   }<br>   // A bare `a --&gt; b` has no shape to hold a label; give it the default one.<br>   if (declaration.shapeFrom !== undefined &amp;&amp; declaration.shapeTo !== undefined) {<br>       return splice(source, declaration.shapeFrom, declaration.shapeTo, `[${text}]`);<br>   }<br>   return splice(source, declaration.idTo, declaration.idTo, `[${text}]`);<br>}</pre><p>Ideally, Mermaid’s own parser would say where each piece of the diagram sits in the text. Mermaid’s newer diagram types are parsed with Langium, which returns a typed syntax tree whose nodes record their exact offset and length in the source. Flowcharts, though, haven’t been migrated yet. They still use Mermaid’s older Jison grammar, which Mermaid now marks as deprecated, and Jison hands back the finished diagram data with no record of where anything came from in the text. To edit the source precisely, you need a second parser that keeps positions.</p><p>So each edit parses the current source using a separate Lezer grammar for Mermaid from the <a href="https://github.com/inspirnathan/codemirror-lang-mermaid">codemirror-lang-mermaid</a> package, but it doesn’t interpret the diagram. It only records where each node ID, shape bracket, and label sits in the text. The edit then replaces just that piece, so the rest of the source, including comments and formatting, stays exactly as the author wrote it.</p><p>There’s one of these functions per action, and each one deals with corner cases of Mermaid syntax so the UI doesn’t have to.</p><p>The React side is equally small. Every handler on the node toolbar runs one of these functions on the current source and hands the result back to the same state the editor writes to:</p><pre>// src/app.tsx<br><br>onLabelChange: (id, label) =&gt; apply(setNodeLabel(sourceRef.current, id, label)),<br>onShapeChange: (id, shape) =&gt; apply(setNodeShape(sourceRef.current, id, shape)),<br>onFillChange: (id, fill) =&gt; apply(setNodeFill(sourceRef.current, id, fill)),</pre><p>Any change, whether typed or made on the canvas, is handled in the same way. There are no separate processes for canvas and editor edits, so they always stay in sync. Since every edit only updates the text, it’s easy to test these changes, and the repo includes unit tests for edits like removing elements or updating labels and links.</p><h3>Details that make it feel like an editor</h3><p>A two-way binding is easy to describe and surprisingly easy to get subtly wrong. Most of the remaining code in the demo is about making it feel instant and predictable.</p><h4>Selection without feedback loops</h4><p>The text and diagram don’t directly control each other. Instead, the app manages selection in one central place. Whenever you interact with either side, that action is reported up, so the app then knows what to display in both the text and the diagram.</p><pre>// src/app.tsx<br><br>interface Selection {<br>   readonly ids: readonly CellId[];<br>   readonly origin: &#39;canvas&#39; | &#39;editor&#39;;<br>}</pre><p>For example:</p><ul><li>Clicking a node in the diagram highlights all its matches in the text and scrolls the first one into view, which is helpful when you want to find the code for a shape you see.</li><li>Moving the caret in the text editor selects and centers the matching node in the diagram.</li></ul><p>By letting the app handle selection, changes don’t bounce back and forth between the text and the diagram. This keeps everything in sync without causing endless update loops.</p><h4>Optimized for production-grade use cases</h4><p>The demo, as it’s always the case with JointJS application templates, is optimized for performance, from the big picture to the smallest details.</p><p>Typing is debounced by 300 ms, so the editor is not parsing text on every keystroke. But actions like picking a shape, loading an example, or hitting undo happen right away without any delay. This avoids lag and keeps the app feeling quick and responsive.</p><p>Two heavy dependencies, Mermaid and Monaco, are loaded with dynamic imports, so each comes in its own chunk instead of the app’s main bundle. And since JointJS for React works with declarative cell records, an edit that only changes a label or a color updates the existing graph instead of rebuilding it.</p><h4>Accessible by default</h4><p>As with any JointJS app template, we paid special consideration to accessibility.</p><iframe src="https://cdn.embedly.com/widgets/media.html?src=https%3A%2F%2Fplayer.vimeo.com%2Fvideo%2F1242772585%3Fapp_id%3D122963&amp;dntp=1&amp;display_name=Vimeo&amp;url=https%3A%2F%2Fvimeo.com%2F1242772585&amp;image=https%3A%2F%2Fi.vimeocdn.com%2Fvideo%2F2221110359-32810a9c7117d64b432437b2eda5de93efa6987d2368b91d71d7614ec50780d7-d_1280%3Fregion%3Dus&amp;type=text%2Fhtml&amp;schema=vimeo" width="1920" height="1097" frameborder="0" scrolling="no"><a href="https://medium.com/media/c63046e767eb0f1b3e779d1b3f1c18a7/href">https://medium.com/media/c63046e767eb0f1b3e779d1b3f1c18a7/href</a></iframe><p>The app works with screen readers, everything is accessible with keyboard, text not only has sufficient contrast but also looks great in both themes, and reduced-motion preferences are respected, enabling users to disable unnecessary animations (@media (prefers-reduced-motion: reduce) {}).</p><h3>Embedding the Mermaid editor in your React app</h3><p>The demo is a complete app, built from two pieces you can embed into your own product. The Mermaid logic is in src/mermaid/ and the React components in src/components/. The app shell in app.tsx holds the raw text as state and connects the two:</p><pre>// src/app.tsx (simplified)<br><br>&lt;EditorPanel<br>   source={source}<br>   onSourceChange={handleSourceChange}<br>   onCursorNodeChange={selectFromEditor}<br>   highlightedIds={selection.origin === &#39;canvas&#39; ? selection.ids : NO_IDS}<br>/&gt;<br><br>&lt;MermaidDiagram<br>   direction={rendered.direction}<br>   layout={rendered.layout}<br>   cells={rendered.cells}<br>   selectedIds={selection.ids}<br>   onSelect={selectFromCanvas}<br>   edit={edit}<br>   linkEdit={linkEdit}<br>/&gt;</pre><p>Notice that the diagram component, MermaidDiagram, never sees the Mermaid text. It receives a list of shapes and links to draw, and when the user changes something, it reports the change. The app shell turns that info into updated Mermaid text and passes the new shapes back down. Because the component only draws and reports, you can plug it into any app that stores Mermaid text:</p><ul><li><strong>The source can live anywhere.</strong> Load your own Mermaid text from anywhere, such as a Markdown file, a database field, or an LLM response, and let your users edit it visually, then save the Mermaid text back. There’s no extra diagram format to store.</li><li><strong>The code editor is optional.</strong> EditorPanel and MermaidDiagram are completely separate components. Developers probably want both side by side, but for non-technical users, you can show only the canvas and its toolbars, and keep Mermaid behind the scenes.</li><li><strong>The Mermaid logic is plain TypeScript.</strong> Parsing Mermaid flowchart source is done in parse.ts, which contains no React or canvas code, so you can easily extend it for the parts of Mermaid your users rely on.</li><li><strong>Theming is done with CSS Custom Properties.</strong> Color themes (both light and dark) are set entirely in CSS variables (index.css), so you can easily tweak them to match your own brand and product style.</li></ul><h3>Use the Mermaid Editor in your projects, from docs platforms to AI assistants</h3><p>If you read our<a href="https://www.jointjs.com/blog/how-to-build-production-grade-data-modeling-apps-in-react-a-jointjs-architecture-walkthrough"> Data Modeling App Template walkthrough</a>, the shape of this app will look familiar. In Data Modeling Demo, SQL DDL serves as the text format, and the graph carries the schema. In Mermaid Editor Demo, Mermaid functions as the text format, and the source carries the diagram. In both cases:</p><ul><li>One thing is the source of truth, and everything else is derived from it.</li><li>The domain logic (SQL generation and parsing in Data Modeling, and Mermaid parsing and source edits here) doesn’t depend on the canvas, so it’s testable on its own.</li><li>A single function maps the domain model to cells, and JointJS for React renders those cells declaratively.</li><li>Nodes are React components, and the interaction layer (selection, scrolling, zooming, layout, export) comes from the library instead of being rebuilt by hand.</li></ul><p>That makes the demo a useful starting point well beyond flowcharts. A few places it fits naturally:</p><ul><li><strong>Docs and knowledge-base platforms</strong> that already store Mermaid in Markdown, so you can easily give non-technical users a visual way to edit it, without changing the storage format.</li><li><strong>AI assistants and agents</strong> that generate flowcharts as Mermaid. LLMs are good at writing Mermaid and not great at getting a diagram exactly right on the first try. A visual editor on top lets users fix the last 10% by clicking instead of re-prompting.</li><li><strong>Internal tools and wikis</strong> where diagrams live in Git and need to stay reviewable as text diffs.</li><li><strong>Other text-based diagram formats.</strong> Swap parse.ts and edit-source.ts for another grammar (another Mermaid diagram type, PlantUML, D2, Graphviz DOT, or your own DSL), and most of the rendering and interaction layer stays as it is.</li></ul><p>The current demo covers Mermaid flowcharts. Other Mermaid types like sequence or state diagrams would need their own mapping in toCells and their own source edits, but the architecture doesn&#39;t change.</p><h3>Getting started</h3><p>The quickest way to see what this does is to<a href="https://jointjs.com/demos/mermaid-editor"> open the live Mermaid Editor demo</a> and paste in a flowchart of your own. Pick something from a real README, or ask your favorite LLM to generate one. Then click around, rename a node, change an arrow, switch the layout direction, and watch the source follow along.</p><p>When you’re ready to embed it in your own app, download the app template locally:</p><pre>npx @joint/cli download mermaid-editor/react</pre><p>You’ll need access to the JointJS+ for React package, through a license or a<a href="https://www.jointjs.com/free-trial"> free trial</a>. The full source is on GitHub:<a href="https://github.com/clientIO/joint-demos/tree/main/mermaid-editor"> clientIO/joint-demos/mermaid-editor</a>.</p><p>Like our other demos, the codebase is heavily commented with the reasoning behind each decision, which makes it a good fit for an AI coding agent. Point your agent at it, describe your use case, and let it adapt the demo. For best results, set up the<a href="https://docs.jointjs.com/learn/help-center/mcp-server/"> JointJS MCP Server</a>, which gives your agent direct access to up-to-date JointJS docs and demo code.</p><p>Happy diagramming!</p><ul><li><a href="https://jointjs.com/demos/mermaid-editor">Try the Mermaid Editor demo</a></li><li><a href="https://github.com/clientIO/joint-demos/tree/main/mermaid-editor">Browse the source on GitHub</a></li><li><a href="https://docs.jointjs.com/react/">Read the JointJS for React docs</a></li><li><a href="https://www.jointjs.com/free-trial">Start your free JointJS+ trial</a>‍</li></ul><p>—</p><h3>FAQ</h3><h4><strong>What is the JointJS Mermaid Editor?</strong></h4><p>It’s an app template built with JointJS+ for React that turns Mermaid flowchart source into an interactive, editable diagram. Changes made on the canvas are written back into the Mermaid text, so the source always stays the single source of truth.</p><h4><strong>How is this different from the Mermaid Live Editor?</strong></h4><p>The Mermaid Live Editor renders a static preview of your text. The JointJS Mermaid Editor renders a live JointJS graph you can edit directly, from renaming nodes and changing shapes and styles to adding and connecting steps, restyling links, and switching the layout direction, with every change synced back to the source.</p><h4><strong>How is this different from Mermaid’s Advanced Editor?</strong></h4><p>The Advanced Editor is the editor in mermaid.ai, Mermaid’s subscription-based platform. It bundles AI generation, saved diagrams, and collaboration with a Visual Editor for canvas editing. The JointJS editor offers the same kind of two-way editing for flowcharts, but as a template you embed in your own React app.</p><h4><strong>Can I easily embed the Mermaid Editor in an existing React app?</strong></h4><p>Yes. The editor uses React components to handle diagram updates, while your app manages the Mermaid text. You can keep the source anywhere you like, from a Markdown file, to a database, or from an LLM response, and add the code editor panel only if your users want to see or edit the text.</p><h4><strong>Does it use a custom Mermaid parser?</strong></h4><p>No. It uses Mermaid’s own parser to read the diagram, so syntax support follows Mermaid itself. A separate Lezer grammar locates exact text spans so canvas edits can be applied without reformatting the rest of the source.</p><h4><strong>Which Mermaid features are supported?</strong></h4><p>Flowcharts, including all classic node shapes, the extended v11 @{ shape: … } catalog, image nodes, nested subgraphs, style, classDef, click, linkStyle, link labels, arrow types, curves, animated links, and Mermaid&#39;s layout: elk option.</p><h4><strong>Can I export the result?</strong></h4><p>Yes. You can export the diagram as SVG or download the Mermaid source as a .mmd file that works anywhere Mermaid is supported.</p><h4><strong>Can I adapt it for other diagram formats?</strong></h4><p>Yes. Parsing and source editing are separated from rendering, so you can use different formats, such as another Mermaid diagram type or your own DSL, and keep most of the canvas and interaction code.</p><p><em>Originally published at </em><a href="https://www.jointjs.com/blog/how-to-embed-a-visual-mermaid-editor-in-your-react-app"><em>https://www.jointjs.com</em></a><em>.</em></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=cc898c0e499e" width="1" height="1" alt=""><hr><p><a href="https://medium.com/diagramming-for-developers/how-to-embed-a-visual-mermaid-editor-in-your-react-app-cc898c0e499e">How to embed a visual Mermaid editor in your React app</a> was originally published in <a href="https://medium.com/diagramming-for-developers">Diagramming for Developers</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[How to get started with JointJS for React]]></title>
            <link>https://medium.com/diagramming-for-developers/how-to-get-started-with-jointjs-for-react-a50f55385f24?source=rss-04b9828fb6b2------2</link>
            <guid isPermaLink="false">https://medium.com/p/a50f55385f24</guid>
            <category><![CDATA[react]]></category>
            <category><![CDATA[diagramming]]></category>
            <category><![CDATA[web-development]]></category>
            <category><![CDATA[jointjs]]></category>
            <dc:creator><![CDATA[JointJS]]></dc:creator>
            <pubDate>Thu, 22 Oct 2026 14:43:09 GMT</pubDate>
            <atom:updated>2026-10-22T14:45:57.963Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*RjYN0Obhx7zmXhBZYS4szg.jpeg" /></figure><p>Whether you’re experimenting, building a proof of concept, or ready for a production-grade app, this roadmap will help you find the right starting point.</p><p>We just released<a href="https://docs.jointjs.com/react"> JointJS for React</a> and<a href="https://www.jointjs.com/blog/introducing-jointjs-for-react"> shared a bit about who it is for, why it matters, and why you should start using it</a>.</p><p>In this article, you’ll get a practical, hands-on guide on getting started with JointJS for React. We won’t go into nitty-gritty details here, but instead we’ll give you a clear outline of the best ways you can jump into it without much effort.</p><p>We’ll briefly cover:</p><ul><li>How to start from a ready-made demo (<a href="https://www.jointjs.com/demos/ai-workflow-builder">AI Workflow Builder</a>) and customize it for your project</li><li>Guidance on building your first app step-by-step using the documentation and quickstart guide</li><li>How to use AI Coding Agents to accelerate development, along with quick installation instructions to get you up and running</li><li>A conclusion with tips, next steps, and further resources</li></ul><h3>Start with the AI Workflow Builder demo</h3><p>Instead of building your app from scratch, the best way to start is to use one of the existing JointJS for React demos that’s close to your actual needs, such as AI Workflow Builder, to build your own proof of concept JointJS for React app.</p><iframe src="https://cdn.embedly.com/widgets/media.html?src=https%3A%2F%2Fplayer.vimeo.com%2Fvideo%2F1208077455%3Fapp_id%3D122963&amp;dntp=1&amp;display_name=Vimeo&amp;url=https%3A%2F%2Fvimeo.com%2F1208077455&amp;image=https%3A%2F%2Fi.vimeocdn.com%2Fvideo%2F2177306193-51ab2508d48e546029ee25c3a950cd0bf239e6a93459e80d6ada5dc5b6c0a0a6-d_1280%3Fregion%3Dus&amp;type=text%2Fhtml&amp;schema=vimeo" width="1920" height="1080" frameborder="0" scrolling="no"><a href="https://medium.com/media/25e0efb165febc0d7569fc7b917ccfb5/href">https://medium.com/media/25e0efb165febc0d7569fc7b917ccfb5/href</a></iframe><p>First, we’ll set up an AI Workflow Builder demo project in a new folder. You can download it using the JointJS CLI tool:</p><pre>npx @joint/cli download ai-workflow-editor/react‍</pre><p>Alternatively, you can simply clone the<a href="https://github.com/clientIO/joint-demos/archive/refs/heads/main.zip"> AI Workflow Builder demo GitHub repository</a>.</p><p>Once the demo is downloaded, run npm install to set up all project dependencies. Note that this demo is built in JointJS+ for React, the commercial extension of the open-source, community-driven library, which installs from the private JointJS npm registry, so you’ll need an access token in the .npmrc file to install it.</p><p>You can get the access token in our<a href="https://my.jointjs.com/login"> customer portal</a> or by starting your <a href="https://www.jointjs.com/free-trial">free trial of JointJS+</a>. You can find<a href="https://docs.jointjs.com/learn/help-center/npm-registry/"> more info on setting up the access token in the docs</a>.</p><p>Once you’ve successfully installed the dependencies, run the npm run start command to start the development server. By default, it will start on localhost, port 5173 (http://localhost:5173/).</p><p>Once you have the demo set up, you can either explore the codebase yourself or ask your AI Coding Agent to give you a detailed overview of the project:</p><pre>Give me an overview of this JointJS+ for React codebase, focusing <br>on JointJS and the key things I need to know about the app.‍</pre><p>As expected, Claude Code, the AI Agent I’m using for this demo, examined the codebase in detail and provided a clear overview of key concepts and everything you need to dig into it yourself.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*IiuTZZAS3poePuuJ.png" /><figcaption>An example output of a prompt requesting an overview of JointJS for React codebase.</figcaption></figure><p>You can now start tweaking the demo yourself, or better yet, follow up with your AI Coding agent to precisely tweak it to suit your needs.</p><p>I recommend you use the<a href="https://docs.jointjs.com/learn/help-center/mcp-server/"> JointJS MCP Server</a> to get direct access to the latest, up-to-date JointJS docs. Even without the MCP server, your AI coding agent will be able to figure out precisely what it needs to do by analyzing JointJS code, but using the MCP server is more efficient and will get you better results in the end.</p><p>Also, if you’re using JointJS MCP Server, you don’t have to manually clone the demo; you can just ask AI to tweak the JointJS for React AI Workflow Builder demo, and AI will set up everything for you.</p><h3>Build your first app step by step by following our quickstart guide</h3><p>Using AI Coding agents to tweak one of our prebuilt demos is the simplest and most efficient way of starting if you’re building a proof of concept and plan to build a serious, production-grade app.</p><p>But if you want to learn more about JointJS for React, if you want to understand key concepts to be able to review AI agent’s changes and to be able to direct your AI coding agent better, it’s best to get your hands dirty by following our<a href="https://docs.jointjs.com/react/getting-started/"> JointJS for React Quickstart Guide</a> in the docs.</p><p>The guide is structured into multiple chapters, and each chapter focuses on one key concept, so it’s easy and straightforward to follow:</p><ol><li>Install @joint/react: add the package, import the styles, and size the canvas.</li><li>Build your first diagram: render elements from plain data.</li><li>Add and update elements: read the graph and change it while the app runs.</li><li>Create custom elements: rich, data-driven nodes with ports, styled your way.</li><li>Connect elements with links: arrowheads, labels, and routing.</li><li>Make the canvas interactive: dragging, clicks, and selection.</li><li>Zoom and pan the canvas: an infinite, scrollable, zoomable viewport with JointJS+.</li><li>Add an element palette: drag from a palette onto the canvas.</li><li>Add a property editor: edit the selected node from a live inspector.</li><li>Add an element overlay: React UI anchored to an element, such as a badge, toolbar, or popover.</li><li>Add a minimap: a bird’s-eye view that tracks the canvas.</li></ol><p>The quickstart guide is designed to be straightforward and approachable for everyone, clearly outlining all key concepts of the library as you encounter them.</p><p>By the end of the guide, you’ll build a complete workflow editor that includes all the key features you’ll find in flowcharts and diagrams, from palette, canvas, minimap, to a live properties panel, giving you insight into JointJS open-source and JointJS+ commercial features.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*xbtZv1K6Y5CzV7AL.png" /><figcaption>A final state of a diagramming app built by following JointJS for React quickstart guide.</figcaption></figure><h3>Use AI Coding agents to set up your JointJS for React project from scratch</h3><p>If you want to start completely from scratch, or add JointJS for React to your existing project, install the library directly from NPM. The open-source version of the library is available at @joint/react, and the commercial extension, JointJS+ for React, is available on NPM at @joint/react-plus.</p><h4>Install JointJS for React through NPM</h4><p>For this demo, we’ll start from scratch and use the Vite build tool to set up a simple React project:</p><pre>npm create vite@latest jointjs-for-react-demo -- --template react-ts‍</pre><p>Next, we need to install JointJS for React, the open-source version of the library. The package is available at<a href="https://www.npmjs.com/package/@joint/react?activeTab=readme"> @joint/react</a>:</p><pre>npm install @joint/react‍</pre><p>This will work with any modern React setup, so you can easily drop it into Vite, Next.js, Remix, and so on. Just as well, you can use JointJS+ for React instead of the open-source version.</p><pre>npm install @joint/react-plus</pre><p>For this guide, we’ll use the open-source version of the library, but JointJS+ for React includes everything from JointJS for React and works exactly the same (the only difference being that &lt;GraphProvider /&gt; in JointJS+ becomes &lt;Diagram /&gt;. And of course, it also gives you access to selection, history, clipboard, spatial index, and more.), just with an expanded set of features.</p><p>Once our React project is up and running and the JointJS for React package is installed, we’ll set up a simple JointJS canvas. The easiest way to start is to use an AI Coding agent to set up the boilerplate project.</p><h4>Set up a basic JointJS canvas with your AI Coding agent</h4><p>Most developers these days use AI Coding Agents extensively in development, just as they should. And this is precisely where JointJS for React shines. JointJS for React is strongly typed, so your AI Coding agents can easily parse the library and understand exactly how it works and how it can give you the result you want.</p><p>You can feel confident using JointJS for React even if you don’t want to wait for the AI training sets to update and kick in with new<a href="https://docs.jointjs.com/react/"> JointJS for React docs</a>. Better yet, you can install<a href="https://docs.jointjs.com/learn/help-center/mcp-server/"> JointJS MCP Server</a>, which provides direct access to up-to-date JointJS docs, including React, to achieve higher-quality code overall.</p><pre>Replace the React demo and build a @joint/react app with a canvas graph, <br>paper, and two rectangles I can drag. Add one input port on the left <br>and one output port on the right to the rectangles, and draw a link <br>from the output port of the first rectangle to the input port of the <br>second rectangle.<br><br>Make the styling slick, modern, and clean with plenty of padding.</pre><p>Note that I’m explicitly mentioning the <em>@joint/react</em> package so the AI Coding Agent knows exactly what to use. I’m using Claude Code in this article, but this will work with any other setup as well.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*bqcS-c8BNlrE53RZ.png" /><figcaption>An example of a JointJS for React app built with an AI Coding Agent through a single prompt.</figcaption></figure><p>AI Agent set up a simple JointJS for React canvas and configured the app precisely as it needs to:</p><pre>import { GraphProvider, Paper, HTMLHost, linkRoutingSmooth, type ElementPort, type CellRecord } from &#39;@joint/react&#39;;<br>import &#39;@joint/react/styles.css&#39;;<br>import &#39;./App.css&#39;;<br><br>function App() {<br>  return (<br>    &lt;div className=&quot;canvas-page&quot;&gt;<br>      &lt;header className=&quot;canvas-header&quot;&gt;<br>        &lt;h1&gt;JointJS + React&lt;/h1&gt;<br>        &lt;p&gt;Drag the rectangles around the canvas&lt;/p&gt;<br>      &lt;/header&gt;<br>      &lt;div className=&quot;canvas-frame&quot;&gt;<br>        &lt;GraphProvider initialCells={initialCells}&gt;<br>          &lt;Paper<br>            renderElement={RectangleNode}<br>            linkRouting={linkRoutingSmooth()}<br>            defaultLink={{ style: { color: &#39;#7c3aed&#39;, width: 2.5, targetMarker: &#39;arrow&#39; } }}<br>            gridSize={20}<br>            drawGrid={{ name: &#39;dot&#39;, args: { color: &#39;#d8d3e6&#39;, thickness: 1.5 } }}<br>            background={{ color: &#39;#faf9fc&#39; }}<br>            className=&quot;canvas&quot;<br>          /&gt;<br>        &lt;/GraphProvider&gt;<br>      &lt;/div&gt;<br>    &lt;/div&gt;<br>  );<br>}<br><br>export default App;</pre><p>The RectangleNode function is responsible for turning the element&#39;s data into React UI. It uses HTMLHost so the element can be plain HTML:‍</p><pre>function RectangleNode({ label, hint }: NodeData) {<br>  return (<br>    &lt;HTMLHost useModelGeometry className=&quot;node&quot;&gt;<br>      &lt;span className=&quot;node__hint&quot;&gt;{hint}&lt;/span&gt;<br>      &lt;span className=&quot;node__label&quot;&gt;{label}&lt;/span&gt;<br>    &lt;/HTMLHost&gt;<br>  )<br>}</pre><p>And the initial elements, ports, and links are configured in their own constants:</p><pre>type NodeData = {<br>  label: string<br>  hint: string<br>}<br><br>const ports: Record&lt;string, ElementPort&gt; = {<br>  in: {<br>    cx: 0,<br>    cy: &#39;50%&#39;,<br>    width: 16,<br>    height: 16,<br>    color: &#39;#ffffff&#39;,<br>    outline: &#39;#c4b5fd&#39;,<br>    outlineWidth: 2,<br>    passive: true,<br>},<br>  out: {<br>    cx: &#39;100%&#39;,<br>    cy: &#39;50%&#39;,<br>    width: 16,<br>    height: 16,<br>    color: &#39;#7c3aed&#39;,<br>    outline: &#39;#ffffff&#39;,<br>    outlineWidth: 2,<br>  },<br>}<br><br>const initialCells: CellRecord&lt;NodeData&gt;[] = [<br>  {<br>    id: &#39;rect-a&#39;,<br>    type: &#39;element&#39;,<br>    position: { x: 120, y: 160 },<br>    size: { width: 220, height: 120 },<br>    portMap: ports,<br>    data: { label: &#39;Rectangle A&#39;, hint: &#39;Output&#39; },<br>  },<br>  {<br>    id: &#39;rect-b&#39;,<br>    type: &#39;element&#39;,<br>    position: { x: 560, y: 160 },<br>    size: { width: 220, height: 120 },<br>    portMap: ports,<br>    data: { label: &#39;Rectangle B&#39;, hint: &#39;Input&#39; },<br>  },<br>  {<br>    id: &#39;rect-a-rect-b&#39;,<br>    type: &#39;link&#39;,<br>    source: { id: &#39;rect-a&#39;, port: &#39;out&#39; },<br>    target: { id: &#39;rect-b&#39;, port: &#39;in&#39; },<br>    style: {<br>      color: &#39;#7c3aed&#39;,<br>      width: 2.5,<br>      targetMarker: &#39;arrow&#39;,<br>    },<br>  },<br>]</pre><p>From here, you can use your AI Coding Agent to tweak and extend it according to your precise project needs. Follow up in your initial prompt to get the result you’re looking for.</p><h3>Conclusion</h3><p>If you want to quickly build a proof of concept for your own use case with JointJS for React, start with the AI Workflow Builder demo and use AI coding agents to tweak it to suit your needs.</p><p>If you want to understand a bit more about how JointJS for React works, follow our<a href="https://docs.jointjs.com/react/getting-started/"> Getting Started Guide</a> in the docs, and in the few short lessons, you’ll learn everything you need to get confident in building production-grade diagramming and flowchart apps.</p><h4>Ready to get started?</h4><ul><li><a href="https://docs.jointjs.com/react">Explore the official JointJS for React documentation for detailed guides and API references</a></li><li><a href="https://www.jointjs.com/demos/ai-workflow-builder">Try the AI Workflow Builder demo</a></li><li><a href="https://www.jointjs.com/free-trial">Learn more about JointJS+ and start a free trial</a></li></ul><p>These resources will help you take your next steps and get the most out of JointJS for React and JointJS+ for React.</p><p>Happy diagramming!<br><a href="https://zoranjambor.com/">Z‍oran Jambor</a></p><h3>FAQ</h3><h4><strong>What is the recommended way to start building with JointJS for React?</strong></h4><p>The fastest way is to use the <a href="https://www.jointjs.com/demos/ai-workflow-builder">AI Workflow Builder demo</a> as a starting point. Download or clone the demo, install dependencies (you’ll need a JointJS+ access token for the commercial version), and run it locally. This gives you a working proof of concept that you can customize to your needs.</p><h4><strong>How do I install JointJS for React in a new or existing project?</strong></h4><p>For open-source, run npm install @joint/react. For the commercial extension, run npm install @joint/react-plus (requires private npm access). Both can be integrated into any modern React setup like Vite, Next.js, or Remix.</p><h4><strong>What’s the difference between JointJS for React and JointJS+ for React?</strong></h4><p>JointJS for React is open-source and provides core diagramming tools. JointJS+ for React is a commercial extension with advanced features (selection, history, clipboard, minimap, spatial index, and more), and uses &lt;Diagram /&gt; instead of &lt;GraphProvider /&gt;.</p><h4><strong>Can I use AI Coding Agents with JointJS for React?</strong></h4><p>Yes! JointJS for React is strongly typed and works well with AI Coding Agents (like Claude Code or GitHub Copilot). Agents can help you set up projects, tweak demos, and generate code. Using the <a href="https://docs.jointjs.com/learn/help-center/mcp-server/">JointJS MCP Server</a> gives them direct access to the latest docs for even better results.</p><h4><strong>How can I learn the basics and key concepts of JointJS for React?</strong></h4><p>Follow the <a href="https://docs.jointjs.com/react/getting-started/">Quickstart Guide</a> in the official docs. It covers installation, rendering diagrams, custom elements, interactivity, palettes, property editors, overlays, and minimaps — everything needed to build a production-grade workflow editor.</p><h4><strong>Do I need a commercial license to try JointJS for React?</strong></h4><p>No, the open-source version is free to use. To try advanced features in JointJS+, <a href="https://www.jointjs.com/free-trial">start a free trial for access to the commercial package and features</a>.</p><h4><strong>Where can I find more resources?</strong></h4><p>Best ways to continue your journey with JointJS for React are:</p><ul><li><a href="https://docs.jointjs.com/react">JointJS for React documentation</a></li><li><a href="https://www.jointjs.com/demos/ai-workflow-builder">AI Workflow Builder demo</a></li><li><a href="https://www.jointjs.com/free-trial">JointJS+ for React free trial</a></li></ul><p><em>Originally published at </em><a href="https://www.jointjs.com/blog/how-to-get-started-with-jointjs-for-react"><em>https://www.jointjs.com</em></a><em>.</em></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=a50f55385f24" width="1" height="1" alt=""><hr><p><a href="https://medium.com/diagramming-for-developers/how-to-get-started-with-jointjs-for-react-a50f55385f24">How to get started with JointJS for React</a> was originally published in <a href="https://medium.com/diagramming-for-developers">Diagramming for Developers</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[JointJS for React: Production-grade diagramming for React]]></title>
            <link>https://medium.com/diagramming-for-developers/jointjs-for-react-production-grade-diagramming-for-react-529328d77146?source=rss-04b9828fb6b2------2</link>
            <guid isPermaLink="false">https://medium.com/p/529328d77146</guid>
            <category><![CDATA[typescript-with-react]]></category>
            <category><![CDATA[ai-workflow-automation]]></category>
            <category><![CDATA[diagramming]]></category>
            <category><![CDATA[react]]></category>
            <dc:creator><![CDATA[JointJS]]></dc:creator>
            <pubDate>Thu, 15 Oct 2026 11:56:18 GMT</pubDate>
            <atom:updated>2026-10-16T13:07:22.127Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*pDXGTMCQiHZ15medWzIYHQ.png" /></figure><p>Most diagramming libraries seem promising at first. You can spin up a demo in ten minutes, and it feels like you’ve found the perfect fit. But after a few months, you’re building undo/redo from scratch, fighting to keep the diagram state in sync with your backend, running into roadblocks when customizing UX to your needs, and noticing performance lags as your data grows.</p><iframe src="https://cdn.embedly.com/widgets/media.html?src=https%3A%2F%2Fwww.youtube.com%2Fembed%2FxZ_N3VRR41Q%3Ffeature%3Doembed&amp;display_name=YouTube&amp;url=https%3A%2F%2Fwww.youtube.com%2Fwatch%3Fv%3DxZ_N3VRR41Q&amp;image=https%3A%2F%2Fi.ytimg.com%2Fvi%2FxZ_N3VRR41Q%2Fhqdefault.jpg&amp;type=text%2Fhtml&amp;schema=youtube" width="854" height="480" frameborder="0" scrolling="no"><a href="https://medium.com/media/412a4dbe6d72100acc249e28f9ccc3f8/href">https://medium.com/media/412a4dbe6d72100acc249e28f9ccc3f8/href</a></iframe><p>Most diagramming libraries take you just far enough to be committed, but fall short when it comes to building a polished, production-ready product, especially on a tight timeline.</p><p>Behind the scenes, the hard part of building a diagramming application isn’t drawing boxes and lines, because every library already does that. The real challenge is supporting the sophisticated interactions users expect (UX/UI), from a modern, intuitive, accessible interface to scalability.</p><p>As your<a href="https://www.jointjs.com/blog/jointjs-performance-overview-testing-diagrams-with-100-000-nodes"> diagrams grow from a few nodes to hundreds or thousands</a>, performance has to keep up. And if you’re working in React, you want an integration that feels like React, not a constant struggle with side effects and useRefs.</p><h3>What JointJS for React actually is</h3><p>JointJS has been powering diagramming applications used by millions of people for over a decade, from AI workflow builders and BPMN modelers to industrial automation dashboards, data modeling tools, and much more. Industry leaders worldwide trust it for diagrams that need to work reliably in production.</p><p>The JointJS engine solves hard problems, including smart routing algorithms that avoid node overlap, consistent hit testing at any zoom level, DOM management, exceptional UX, outstanding performance, and memory management in production environments.</p><p>JointJS for React brings that trusted engine directly to React. This isn’t just a wrapper or a clunky compatibility layer, but a truly idiomatic React API built on top of JointJS.</p><p>Diagram state is React state, with a core wrapper component ( GraphProvider / Diagram) that manages and provides it to child components, directly connecting the JointJS engine with React&#39;s lifecycle. There&#39;s no hidden state, no imperative API calls, and no synchronization headaches between React&#39;s render cycle and the canvas. What&#39;s in your state is exactly what&#39;s on the screen.</p><p>Here’s what a simple JointJS app in React looked like until now, and what it will look like going forward.</p><p><strong>Before — JointJS 4.2</strong></p><pre>// DO NOT USE - Old way of integrating JointJS with React<br><br>import { useEffect, useRef } from &#39;react&#39;;<br>import { dia, shapes } from &#39;@joint/plus&#39;;<br><br>function JointJs() {<br>  const canvas = useRef&lt;Element | null&gt;(null);<br><br>   useEffect(() =&gt; {<br>       const graph = new dia.Graph();<br><br>       const paper = new dia.Paper({<br>           model: graph,<br>           background: {<br>               color: &#39;#F8F9FA&#39;,<br>           },<br>           frozen: true,<br>           async: true,<br>           cellViewNamespace: shapes<br>       });<br><br>       canvas.current?.appendChild(paper.el);<br><br>       const rect = new shapes.standard.Rectangle({<br>          type: &#39;standard.Rectangle&#39;,<br>          position: { x: 100, y: 100 },<br>          size: { width: 100, height: 50 },<br>          attrs: { label: { text: &#39;Hello World&#39; } },<br>       });<br><br>       graph.addCell(rect);<br>       paper.unfreeze();<br><br>       return () =&gt; {<br>           paper.remove();<br>       };<br><br>   }, []);<br><br>   return (<br>       &lt;div className=&quot;canvas&quot; ref={canvas}/&gt;<br>   );<br>}<br><br>export default JointJs;</pre><p>The old approach isn’t wrong, but it’s at odds with React’s model. Setup happens inside a useEffect, you access Paper through useRef, and you&#39;re stuck with manual cleanup.</p><p><strong>After — JointJS for React</strong></p><pre>// New way — JointJS for React<br><br>  import { GraphProvider, Paper } from &#39;@joint/react&#39;;<br><br>  const initialCells = [<br>    {<br>      type: &#39;element&#39;,<br>      position: { x: 100, y: 100 },<br>      data: { label &#39;Hello World&#39; },<br>    },<br>  ];<br><br>  export default function App() {<br>    return (<br>      &lt;GraphProvider initialCells={initialCells}&gt;<br>        &lt;Paper className=&quot;canvas&quot; /&gt;<br>      &lt;/GraphProvider&gt;<br>    );<br>  }</pre><p>JointJS for React fits right in with the rest of your React codebase. You declare what you want, and the framework takes care of the rest. It’s not just more elegant, but actually simpler and more intuitive, too.</p><h3>The difference between JointJS for React and JointJS+ for React</h3><p>In this article, we’ll focus on JointJS+ for React, so it’s worth noting what the actual differences from the open-source version of the library are. Both versions are based on the JointJS diagramming engine.</p><p>JointJS for React is a free, community-driven diagramming library. It gives you the core SVG + HTML rendering engine, a solid API, and building blocks for flowcharts, UML, and other diagramming applications. (If you give the open-source version a try and find it helpful, <a href="https://github.com/clientIO/joint/tree/master/packages/joint-react">consider leaving a star on GitHub</a>. It’s a small thing, but it means a lot to the team — thanks!))</p><p>JointJS+ for React is a commercial extension built on the same core engine, adding numerous ready-to-use UI plugins for snapping, panning, zooming, tooltips, and context menus, plus advanced shapes/styling options on top of what’s in the open-source version. It also adds production-focused components not in JointJS at all, like the CommandManager for unlimited undo/redo history tracking, multi-select, and Snaplines/measurement shapes for precision alignment.</p><p>JointJS+ includes everything in JointJS and builds on top of it, so it’s really a question of whether you want to build the UI layer yourself or have the library do the heavy lifting for you.</p><blockquote><strong>Already a JointJS+ customer?</strong></blockquote><blockquote>Download the latest package, including JointJS+ for React, <a href="https://docs.jointjs.com/learn/help-center/npm-registry">using npm</a> or from our <a href="https://my.jointjs.com/">customer portal</a>. If your update subscription expired, <a href="https://www.jointjs.com/contact-us">reach out to us</a> for re-activation.</blockquote><blockquote><strong>New to JointJS+?</strong> Start a <a href="https://www.jointjs.com/free-trial">30-day no-commitment trial</a>, which now includes JointJS+ for React.</blockquote><h3>AI Workflow Builder with JointJS+ for React</h3><p>Workflow editors like pipeline designers, approval flows, and data-processing graphs are among the most common diagramming apps teams build, and they’re a great benchmark for any library. They let you quickly see whether a tool handles both the basics and the edge cases.</p><p>Rendering boxes and arrows is easy; what takes significant effort in development are the editing interactions users expect, connection rules that keep the graph semantically valid, configuration options, and performance that holds up as your diagram grows. This demo directly addresses those challenges.</p><p>Live demo: <a href="https://www.jointjs.com/demos/ai-workflow-builder">https://www.jointjs.com/demos/ai-workflow-builder</a></p><iframe src="https://cdn.embedly.com/widgets/media.html?src=https%3A%2F%2Fplayer.vimeo.com%2Fvideo%2F1208077455%3Fapp_id%3D122963&amp;dntp=1&amp;display_name=Vimeo&amp;url=https%3A%2F%2Fvimeo.com%2F1208077455&amp;image=https%3A%2F%2Fi.vimeocdn.com%2Fvideo%2F2177306193-51ab2508d48e546029ee25c3a950cd0bf239e6a93459e80d6ada5dc5b6c0a0a6-d_1280%3Fregion%3Dus&amp;type=text%2Fhtml&amp;schema=vimeo" width="1920" height="1080" frameborder="0" scrolling="no"><a href="https://medium.com/media/25e0efb165febc0d7569fc7b917ccfb5/href">https://medium.com/media/25e0efb165febc0d7569fc7b917ccfb5/href</a></iframe><p>The same engine powering this AI Workflow Builder also drives BPMN editors, industrial automation (SCADA/HMI), energy network visualization, circuit design, data modeling tools, and more. The domain might change, but the engine’s strengths remain the same. A workflow editor puts most of these capabilities to the test, making it the perfect starting point.</p><h4>1. Diagram basics done right</h4><p>The diagram nodes in this demo (Input, AI Agent, Tool, Output) aren’t just rectangular boxes-they’re fully configurable UI components. Each node can render arbitrary HTML content, including headers, icons, text areas, select boxes, sliders, and other interactive controls. Combined with visual cues like colored icons and port legends, the graph remains easy to scan and understand at a glance.</p><pre>// src/components/nodes/render-node.tsx<br><br>function NodeBody({ data }: { data: ConfigNodeData }) {<br> switch (data.kind) {<br>   case &#39;input&#39;:  return &lt;TextInputBody data={data} /&gt;;<br>   case &#39;skill&#39;:  return &lt;SkillBody data={data} /&gt;;<br>   case &#39;agent&#39;:  return &lt;AgentBody data={data} /&gt;;<br>   case &#39;tool&#39;:   return &lt;ToolBody data={data} /&gt;;<br>   case &#39;output&#39;: return &lt;OutputBody data={data} /&gt;;<br> }<br>}</pre><h4>2. Editing interactions</h4><p>Undo/redo, copy/paste, multi-select, keyboard shortcuts, snap-to-grid are all essential features users expect from serious apps. If you’ve ever tried building them from scratch, you know they’re far from easy to get right.</p><p>In this demo, history and clipboard are single props on the root component:</p><pre>// src/app.tsx<br><br>&lt;Diagram cells={cells} onCellsChange={setCells} history clipboard&gt;</pre><p>The real value isn’t just that these features exist, but that they work together seamlessly. Undo correctly reverses a paste, multi-select moves as a group and lands on the undo stack as a single action, while <a href="https://docs.jointjs.com/api/ui/Snaplines/">Snaplines</a> (a JointJS feature for aligning elements) work no matter how a node was placed. Only a library that builds these features into the engine can guarantee they’ll play nicely together.</p><h4>3. The data model</h4><p>This is what matters in serious, production-grade applications, and in JointJS+ for React, the diagram state is plain React state. Just as you’re used to working with React, Diagram can take data in either uncontrolled or controlled state. This demo showcases the controlled state.</p><pre>// src/app.tsx<br><br>const [cells, setCells] = useState&lt;readonly WorkflowCell[]&gt;(INITIAL_CELLS);<br><br>&lt;Diagram cells={cells} onCellsChange={setCells} history clipboard /&gt;</pre><p>The controlled cells array is the single source of truth. It’s rendered on the &lt;Diagram /&gt;, while every user action fires onCellsChange with an updated array. Because the graph is just a serializable data structure, saving, loading, and processing are trivial.</p><p><em>Note that the state hooks in JointJS for React behave identically in JointJS and JointJS+ but in JointJS+, GraphProvider becomes Diagram, which also gives you access to selection, history, clipboard, spatial index, and more.</em></p><h4>4. Layout and organization</h4><p>Diagrams that developers create by hand often drift toward visual noise. The auto-arrange option resolves this in a single action, in which a layout algorithm runs over the graph and repositions every node cleanly.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*aA1BWRFSgFGWfowA.png" /></figure><p>At the canvas/paper level, there are two available modes: an infinite-scrollable canvas for open-ended building, and a fixed sheet mode that restricts the diagram’s canvas to specific, page-like boundaries, which is ideal for exportable documents such as flowcharts, organization charts, or diagrams that must fit strict corporate reporting templates.</p><p>The minimap in the bottom-right corner becomes vital as soon as the diagram grows beyond the viewport size. In JointJS+ for React, this is just one of the components you can plug into your application with a few lines of code.</p><h4>The purpose of AI Workflow Builder demo</h4><p>This demo clearly demonstrates what a serious AI workflow editor looks like when it’s built on a complete diagramming engine.</p><p>Every feature shown here, from typed connections, undo/redo, clipboard, multi-select, auto-layout, export, to minimap, is available on day one as a core feature of the JointJS library.</p><p>JointJS handles the hard parts out of the box, so you can focus on building your application logic instead of spending months implementing core library features.</p><h3>Key capabilities of JointJS+ for React — What you get out of the box</h3><p>JointJS+ for React provides a valuable set of features for production-ready diagrams, not just demos. These capabilities make JointJS+ for React a true foundation for serious diagramming applications, eliminating the need to reinvent critical features and assuring your product is ready for actual real-world demands.</p><h4>SVG-based rendering with full custom shape support</h4><p><a href="https://www.jointjs.com/blog/svg-versus-canvas">JointJS uses a combination of SVG and HTML as its rendering engine</a>, which means your diagrams will remain crisp at any zoom level, while the added benefit of SVG being accessible means your applications will meet necessary accessibility standards more easily.</p><p>On top of that, in JointJS you’re never limited to built-in shapes. You can easily create any kinds of elements. Nodes can use SVG or HTML, with wrapped labels, interactive inputs, and live data. All JointJS elements work flawlessly with ports, links, and selection, so you’ll never have to resort to workarounds.</p><h4>Built-in virtual rendering for large graph performance</h4><p>JointJS comes with extensive options that let you configure it for scalability and performance, but it ships with conservative defaults, primarily for backward compatibility. JointJS+ for React, on the other hand, doesn’t come with this baggage, so all advanced JointJS performance options like async, autoFreeze, and viewManagement you&#39;d want in a large-scale application are enabled by default.</p><p>All of this means that instead of thinking about what you need to do to make your large apps performant, you can just start building with confidence, knowing that everything is already set up for you, even if you plan to build diagrams with thousands of nodes.</p><h4>Exceptional user experience (UX)</h4><p>JointJS+ for React is built to deliver a frustration-free diagramming experience for both end users and developers. The library provides intuitive drag-and-drop interactions, smooth editing, instant feedback, and advanced features such as minimap, smooth zoom controls, different routers, and more.</p><h4>Domain-specific shape libraries</h4><p>Get fully featured, standards-compliant shapes for BPMN 2.0, value stream mapping, data modeling (records/tables), and charts.</p><p>These shapes aren’t just icons, but they include the correct ports, labels, and connection rules for each domain, allowing you to build real-life applications without starting from scratch.</p><h4>Comprehensive layout algorithms</h4><p>JointJS+ for React comes with built-in tree, force-directed, grid, and stack layouts, while also allowing seamless integration with advanced third-party layout engines such as ELK and Dagre. Easily auto-arrange and reorganize complex diagrams.</p><p>These algorithms make it easy to auto-arrange nodes, keep diagrams readable, and adapt to model changes, saving you weeks of custom development.</p><h4>Rich interaction model</h4><p>Undo/redo, copy/paste, multi-select, keyboard shortcuts, snap-to-grid, and alignment guides work together out of the box, intuitively.</p><p>None of these are bolted on separately and hoped to cooperate: undo correctly reverses a paste, a multi-select move lands on the undo stack as a single action, and snap-to-grid/alignment guides apply no matter how the node got there, be it by dragging, pasting, or dropping it from the stencil.</p><h4>TypeScript-first API</h4><p>The API features complete, first-class TypeScript definitions. From connection validators to custom shapes and serialized cells, everything is strongly typed, allowing autocomplete to work out of the box while giving you the opportunity to catch errors at compile time, making maintenance and refactoring much safer.</p><h4>Effortless export options</h4><p>In JointJS+ for React, you can easily export diagrams as SVG, PNG, or PDF. What users see on screen is exactly what they get in exports, so you won’t need to implement separate rendering logic. Canvas ( paper) options allow you to visualize fixed sheets and page breaks, which is key if you need specific dimensions of diagrams and flowcharts for your documents and presentations.</p><h3>Who is JointJS+ for React built for</h3><p>JointJS+ for React is designed for teams building workflow automation tools, BPMN modelers, data pipeline editors, network topology visualizers, circuit design tools, or any application where diagramming is a core product feature. It’s built for cases where users need robust editing, undo/redo, easy export, and all of this delivered with polished UX and production-grade scalability. When your requirements go beyond simple visuals, and you need a complete, production-ready foundation, JointJS+ for React delivers everything out of the box.</p><p>Simpler libraries are fine for simple needs, but as soon as requirements get serious, whether in performance, intuitive and accessible UX, scalability, or configuration options, you quickly hit a ceiling. At that point, you either have to build the missing pieces yourself or start with the right foundation from day one. Not anymore, because this is precisely the gap that JointJS+ for React fills.</p><h3>Getting started with JointJS+ for React</h3><p>The easiest way to get started with JointJS+ for React is to jump into our <a href="https://www.jointjs.com/demos/ai-workflow-builder">AI Workflow Builder demo</a>. The source is fully available on GitHub, so you can clone the repo, run npm install, and you&#39;re ready to tweak and customize it, either by hand, if you want to dig into the code yourself, or with your AI Coding Agent, be it Claude Code, Codex, Cursor, or any other model you might be using.</p><p>All the principles that apply to<a href="https://www.jointjs.com/blog/tutorial-customize-jointjs-demo-app-with-claude-code"> AI Coding Agents and JointJS</a> also apply to JointJS+ for React. That means you can use your AI Coding Agent and the AI Workflow Builder demo as a great starting point for your own proof of concept, or even project. The documentation is already up to date, so our JointJS MCP Server will help you get started right away, without having to wait for new AI training sets to kick in.</p><h4>Learn more about JointJS+ for React:</h4><ul><li><a href="http://docs.jointjs.com/react">Explore the docs →</a></li><li><a href="https://www.jointjs.com/demos/ai-workflow-builder">Try the AI Workflow Builder demo →</a></li><li><a href="https://www.jointjs.com/free-trial">Start your free JointJS+ trial</a></li></ul><p>Happy diagramming! 👋‍<br><a href="https://zoranjambor.com/">Zoran Jambor</a></p><h3>FAQ</h3><h4>What is JointJS for React?</h4><p>JointJS for React is a production-grade diagramming library designed for React applications. It provides a truly idiomatic React API, connecting the trusted JointJS engine directly with React’s lifecycle without the need for wrappers or workarounds.</p><h4>How is JointJS+ for React different from other diagramming libraries?</h4><p>JointJS+ for React handles everything a serious diagramming library needs, from the essentials to advanced features like undo/redo, copy/paste, multi-select, snap-to-grid, and direct integration with React state.</p><p>Performance as well as scalability are built in from day one, even for large diagrams. On top of this, the library provides superior UX features that will help you create intuitive and usable apps.</p><h4>What kinds of apps is JointJS+ for React best suited for?</h4><p>JointJS+ for React is ideal for AI workflow editors, BPMN modelers, industrial automation dashboards, network visualizations, circuit design tools, and any application where diagramming is a core feature and enterprise-level reliability is required.</p><h4><strong>What are the key features included out of the box in JointJS+ for React?</strong></h4><ul><li>SVG-based rendering with full custom shape support</li><li>High performance for large diagrams (virtual rendering, async updates)</li><li>Comprehensive suite of out-of-the-box user experience (UX) and User Interface (UI) features</li><li>Built-in rich interactions (undo/redo, clipboard, snap-to-grid, keyboard shortcuts)</li><li>Comprehensive layout algorithms (tree, force-directed, grid, and stack layouts)</li><li>Domain-specific shapes (BPMN, value stream, data modeling, and more)</li><li>Effortless export (SVG, PNG, PDF)</li><li>TypeScript-first API</li></ul><h4>Is there a live demo or starter project?Is there a live demo or starter project?</h4><p>Yes! There is an <a href="https://www.jointjs.com/demos/ai-workflow-builder">AI Workflow Builder</a> demo with full source code available. You can explore, clone, and customize it as a starting point for your project.</p><h4>How do I get started?</h4><p>Check out the <a href="https://docs.jointjs.com/react">documentation</a> or try the <a href="https://www.jointjs.com/demos/ai-workflow-builder">live demo</a>. New to JointJS+? <a href="https://www.jointjs.com/free-trial">Start a 30-day no-commitment trial</a>, which now includes JointJS+ for React. If you’re already a JointJS+ customer, download the latest package <a href="https://docs.jointjs.com/learn/help-center/npm-registry">using npm</a> or from our <a href="https://my.jointjs.com/">customer portal</a>. If your update subscription expired, <a href="https://www.jointjs.com/contact-us">reach out to us</a> for re-activation.</p><p><em>Originally published at </em><a href="https://www.jointjs.com/blog/introducing-jointjs-for-react"><em>https://www.jointjs.com</em></a><em>.</em></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=529328d77146" width="1" height="1" alt=""><hr><p><a href="https://medium.com/diagramming-for-developers/jointjs-for-react-production-grade-diagramming-for-react-529328d77146">JointJS for React: Production-grade diagramming for React</a> was originally published in <a href="https://medium.com/diagramming-for-developers">Diagramming for Developers</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
    </channel>
</rss>