[]previous and next page

Quick start

Put a working whiteboard on screen in a few minutes, in the framework you already use.

Pick your setup. Every tab ends with the same thing: a full editor with tools, styles, undo, export and autosave.

index.htmlhtml
<div id="board" style="height: 100vh"></div>
<script type="module" src="./main.ts"></script>
main.tsts
import { createCanvasFlow } from 'canvasflow/dom'
import { mountUI } from 'canvasflow/ui'

const app = createCanvasFlow(document.getElementById('board')!, {
  persistenceKey: 'my-board', // autosave to IndexedDB under this key
})

mountUI(app)

createCanvasFlow mounts the canvas: rendering, input, text editing, clipboard and drag and drop. mountUI adds the default interface on top. Leave it out and you have a blank, fully working canvas for your own UI.

Do something with it#

The editor is the one object you talk to. Every interface gives it to you: app.editor in plain JS, onMount or useEditor() in the framework bindings, onReady in React Native.

hello.tsts
const id = editor.createShape({
  type: 'geo',
  x: 100,
  y: 100,
  props: { geo: 'rectangle', w: 220, h: 120, text: 'Hello', color: 'blue', fill: 'semi' },
})

editor.select(id)
editor.zoomToSelection({ animate: true })

editor.on('change', ({ source }) => {
  if (source === 'user') console.log('Someone edited the board')
})

That's the shape of everything in CanvasFlow: create and update records, listen for changes, and let the editor take care of undo, rendering and sync.

Where to go next#