Skip to content

React component

Render diagrams in a React app with the sfn-diagram-react package (source). It wraps generateSvg/generateMermaid in a component with the same platform-agnostic core, so it works in any React renderer. React 18 and 19 are both supported.

Terminal window
npm i sfn-diagram-react sfn-diagram react
import { SfnDiagram } from 'sfn-diagram-react';
<SfnDiagram
definition={asl} // ASL object or JSON string
format="svg" // 'svg' (default) | 'mermaid'
theme="dark" // 'light' | 'dark' | CustomTheme
layout="LR" // 'TB' | 'LR' | 'RL' | 'BT'
history={history} // optional: renders an execution overlay
onError={(err) => console.error(err)}
/>