Embedding
Mount the studio's components, the workflow canvas first, in your own React app; what is exported, what the host provides, and a working example from this site.
The studio app is built from components that @sendwend/studio also exports, and the CLI composes exactly these: nothing is held back for it. Routes fetch and components render, so the components carry no router and no query client. A host app passes data in as props and keeps ownership of its URLs and data fetching.
The most useful one is WorkflowCanvas: a read-only diagram of a workflow drawn from its compiled IR. This site uses it for every example in the workflow gallery, so a page always shows what the code compiles to rather than a hand-drawn picture of it.
What is exported
| Export | What it renders |
|---|---|
WorkflowCanvas | A workflow's IR as a pan-and-zoom canvas, with optional per-node badges and selection |
WorkflowList | The workflows table: shape, funnel columns and sparklines |
TemplatesPage | A template preview with its envelope, toolbar and optional props editor |
PushPreview | A push notification on iOS and Android lock screens |
MetricCard | A headline number, a period-over-period delta and a chart of one or more series |
Sparkline | A small line of recent values |
DateRangePicker | The range picker the metrics view uses, with lastDays, isoDay, parseIsoDay, formatDay |
Avatar, Button | Small building blocks |
CHANNEL_ICON, ALL_CHANNELS_ICON, channelIcon | The icons per metric channel |
collectTemplateRefs, collectTemplates | Every template a set of IRs references, and where |
layout, CARD_SIZE, ICON_SIZE | The pure IR-to-nodes-and-edges layout the canvas draws |
superellipse | The corner-shape style the studio's cards use |
The root export also re-exports everything in @sendwend/studio/config: defineStats and the stats types (WorkflowReport, NodeStats, MetricPoint, …), so data you fetch yourself can be typed to what the components expect.
WorkflowCanvas
ir is a compiled workflow: workflow(...).toIR(), or one entry of compileConfig(config).workflows. It is plain data, so you can compile on the server and send it to the browser; the canvas never needs your workflow code.
The canvas fills its parent, so give the parent a height. Nodes cannot be dragged. colorMode only affects what react-flow paints itself; the cards and connectors read their colors from CSS variables (below), and follow your theme through them. It is passed in rather than read from the DOM so the host stays in control.
What the host provides
react-flow's stylesheet. The canvas is built on @xyflow/react (a dependency of the studio) and needs its base CSS. Import it once in your global stylesheet:
The color variables. Cards, connectors, the grid and icons are styled inline from these custom properties. The studio defines them for its own app; an embedding host defines them itself:
| Variable | Used for |
|---|---|
--color-canvas | The canvas background |
--color-card | Node card background |
--color-edge | Card borders and connectors |
--color-grid | The background dots |
--color-primary, --color-secondary, --color-muted | Card titles, labels, secondary text |
--color-accent, --color-accent-ring | The selected node |
--color-icon-trigger, --color-icon-message, --color-icon-delay, --color-icon-control, --color-icon-data, --color-icon-exit | Icon colors per node category |
The studio's own theme also defines --color-selected and --color-card-shadow, which other components use; defining them too costs nothing.
A font, optionally. Cards ask for 'Inter Variable', Inter, then fall back to the system UI font.
A working example: this site
The canvas on this site's workflow pages is a small wrapper, apps/web/src/components/workflow-canvas. It makes three choices worth copying.
Load it lazily, in the browser only. react-flow measures the DOM, so there is nothing useful to render on the server. Keeping the import behind lazy() also keeps the studio out of the server bundle (here, a Cloudflare Worker) and its startup time. useSyncExternalStore with a server snapshot of false renders nothing on the server and on the hydration pass, then the canvas once mounted:
A page then renders <WorkflowCanvas ir={ir} className="h-96" />, with the IR compiled on the server by compileConfig.
Scope the variables to a wrapper. Two of the names, --color-card and --color-edge, already mean something else in this site's theme. Defining the canvas's values on a .workflow-canvas class instead of :root keeps both meanings intact. The values map onto the site's palette, with a dark set under the site's .dark class:
--color-primary, --color-secondary and --color-accent are not redefined: the site's own values are the ones wanted.
Restyle react-flow's controls through its variables. The zoom controls are react-flow's own and read --xy-controls-* variables. react-flow's stylesheet sits in @layer xyflow, so an unlayered rule wins without !important:
Live badges and selection
The canvas takes the same data the studio feeds it. To show how many users wait on each node, pass a NodeStats object (node id → count), for example from an endpoint of your own that runs the query @sendwend/studio/postgres uses: running instances of the workflow grouped by node_id. To build an inspector, hold the selected id in state and pass selectedId and onSelectNode; the IR has every node's parameters, and each node's meta.loc records where it was built.
The other components
The canvas is styled entirely inline, which is why the variables above are all it needs. The other components are not:
- Styling.
MetricCard,Sparkline,PushPreview,WorkflowList,TemplatesPageand the rest use Tailwind utility classes against the studio's theme tokens (bg-card,text-muted,border-border, …). A host on Tailwind 4 has to define those tokens and add the package to its sources (@source) for the classes to be generated. - Labels.
WorkflowList,TemplatesPageandDateRangePickercallreact-i18next'suseTranslation()for their labels, and the studio's translation strings are not exported. Without an i18next instance that provides those keys, they render the keys themselves.WorkflowCanvas,MetricCard,SparklineandPushPreviewtake every string they show as props.
Treat the canvas as the component built for embedding, and the rest as available but tied more closely to the studio's own app.