Field Notes
    Preparing search index...

    Field Notes

    Field Notes

    A lightweight, framework-agnostic infinite canvas SDK for the web — with first-class support for embedding interactive HTML elements.

    Site · Playground · Tabletop · Embeds · Dev playground · Bench · API reference

    tldraw — the leading canvas SDK — now requires a commercial license. Field Notes is MIT-licensed, framework-agnostic, and treats embedded HTML elements as first-class citizens alongside freehand drawing, shapes, and annotations. It's the open canvas SDK you can actually ship on.

    How it compares to the alternatives:

    • tldraw — excellent features, but the SDK is now commercially licensed
    • Excalidraw — great drawing tool, but can't embed arbitrary HTML components
    • React Flow — excellent for node graphs, but not a general-purpose canvas

    The @fieldnotes/core engine has zero framework dependencies and drops into any stack; the React, Vue, Svelte and Angular bindings are thin optional layers; and real-time collaboration ships as separate, opt-in packages you own end-to-end.

    Package Description
    @fieldnotes/core Vanilla TypeScript canvas engine — zero framework deps
    @fieldnotes/react React bindings — components, hooks, portal embedding
    @fieldnotes/vue Vue 3.5+ bindings — components, composables, teleport embedding
    @fieldnotes/svelte Svelte 5 bindings — components, store helpers, snippet embedding
    @fieldnotes/angular Angular 20 to 22 bindings — standalone components, signal helpers, content projection
    @fieldnotes/vtt VTT domain package — fog of war, grids, templates, measurement
    @fieldnotes/sync Real-time sync client — observe/apply ops over a pluggable transport
    @fieldnotes/sync-server Authoritative WebSocket relay — rooms, auth, write-authorization
    @fieldnotes/sync-redis Redis persistence + cross-instance fan-out for the relay
    npm install @fieldnotes/core
    
    import { Viewport, SelectTool, PencilTool, HandTool } from '@fieldnotes/core';

    const viewport = new Viewport(document.getElementById('canvas'), {
    background: { pattern: 'dots' },
    });

    viewport.toolManager.register(new SelectTool());
    viewport.toolManager.register(new PencilTool({ color: '#1a1a1a', width: 2 }));
    viewport.toolManager.register(new HandTool());
    viewport.setTool('select');
    const widget = document.createElement('div');
    widget.innerHTML = '<h3>Interactive Card</h3>';

    const button = document.createElement('button');
    button.textContent = 'Click me';
    button.addEventListener('click', () => console.log('It works!'));
    widget.appendChild(button);

    viewport.addHtmlElement(widget, { x: 100, y: 200 });

    See @fieldnotes/core README for the full API documentation.

    npm install @fieldnotes/core @fieldnotes/react
    

    With no tools prop (and no tools registered in onReady) the canvas registers the default tool bundle, so a persisting board is one component (details):

    <FieldNotesCanvas initialData={saved} onChange={save} style={{ width: '100%', height: '100%' }} />
    

    Pass your own tools and embed React components:

    import { FieldNotesCanvas, HostElement, useCamera } from '@fieldnotes/react';
    import { SelectTool, PencilTool, HandTool } from '@fieldnotes/core';

    function App() {
    return (
    <FieldNotesCanvas
    tools={[new SelectTool(), new PencilTool(), new HandTool()]}
    defaultTool="select"
    style={{ width: '100vw', height: '100vh' }}
    >
    <HostElement position={{ x: 100, y: 200 }} size={{ w: 300, h: 200 }}>
    <MyReactComponent />
    </HostElement>
    <CameraInfo />
    </FieldNotesCanvas>
    );
    }

    function CameraInfo() {
    const { x, y, zoom } = useCamera();
    return (
    <div>
    {zoom.toFixed(2)}x at ({x.toFixed(0)}, {y.toFixed(0)})
    </div>
    );
    }

    Embedded React components are fully interactive and pan/zoom with the canvas. See @fieldnotes/react README for the full API.

    npm install @fieldnotes/core @fieldnotes/vue     # Vue 3.5+
    npm install @fieldnotes/core @fieldnotes/svelte # Svelte 5
    npm install @fieldnotes/core @fieldnotes/angular # Angular 20 to 22

    Vue, Svelte and Angular export the component as CanvasElement. React calls it HostElement. All three mirror the React package with FieldNotesCanvas, Minimap, and the React hooks as composables returning refs in Vue, store helpers in Svelte and signal helpers in Angular. Vue and Svelte keep the hook names; Angular renames use to inject (injectCamera) and uses fn- selectors (<fn-canvas>). The canvas mounts on the client; server rendering emits an empty container.

    <FieldNotesCanvas v-model:tool="tool" :initial-data="saved" @change="save" style="height: 100vh">
    <CanvasElement :position="{ x: 100, y: 200 }"><MyCard /></CanvasElement>
    </FieldNotesCanvas>
    <FieldNotesCanvas initialData={saved} onchange={save} style="height: 100vh">
    <CanvasElement position={{ x: 100, y: 200 }}><MyCard /></CanvasElement>
    </FieldNotesCanvas>
    <fn-canvas [(tool)]="tool" [initialData]="saved" (stateChange)="save($event)" style="height: 100vh">
    <fn-canvas-element [position]="{ x: 100, y: 200 }"><my-card /></fn-canvas-element>
    </fn-canvas>

    See the @fieldnotes/vue, @fieldnotes/svelte and @fieldnotes/angular READMEs.

    Keep multiple canvases in sync across devices. @fieldnotes/sync streams element operations over a pluggable transport; @fieldnotes/sync-server is an authoritative WebSocket relay that holds canonical per-room state, answers snapshot-on-join, and supports auth and write-authorization.

    import { Viewport } from '@fieldnotes/core';
    import { SyncClient, WebSocketTransport } from '@fieldnotes/sync';

    const viewport = new Viewport(document.getElementById('canvas'));

    const sync = new SyncClient({
    store: viewport.store,
    transport: new WebSocketTransport('ws://localhost:8080?room=my-room'),
    });
    sync.start(); // observe local edits, apply remote ones, resync on reconnect
    // the relay (its own process)
    import { createSyncServer } from '@fieldnotes/sync-server';

    createSyncServer({ port: 8080 });

    The model is authoritative op-broadcast with last-write-wins (not CRDT). Add @fieldnotes/sync-redis for restart-survival and cross-instance fan-out. See the @fieldnotes/sync-server README for auth, write-authorization, and heartbeat/reconnection.

    • Infinite canvas with pan & zoom (scroll, pinch, two-finger drag, pan inertia)
    • Freehand drawing with stroke smoothing and pressure-sensitive width
    • Sticky notes, text, curved arrows (element-binding, labels), images, shapes (rectangle, ellipse, line)
    • Interactive HTML element embedding (custom renderer registry, double-click to interact)
    • Real-time collaboration — multi-device sync via an authoritative relay (@fieldnotes/sync)
    • Layers with visibility, locking, ordering, and per-layer opacity
    • Select, multi-select, move, resize, rotate, group / ungroup
    • Align, distribute, smart guides, and element-to-element snapping
    • Minimap overview, laser pointer, fit-to-content, zoom presets
    • Command palette (Ctrl/⌘+K) that runs actions and finds text on the board, and a shortcuts help dialog (?)
    • Runtime tool configuration (color, width, smoothing)
    • Undo / redo (one step per drag)
    • State serialization (versioned JSON export/import, CanvasState v4 with extension envelopes)
    • Pluggable persistence (IndexedDB / localStorage storage adapters)
    • PNG and SVG export with scale, padding, and background options
    • Extension system — register custom element types, viewport plugins, render hooks, constraint services, and sync plugins
    • Custom tool API and HTML renderer registry (public extension points)
    • Performance instrumentation (getRenderStats(), logPerformance())
    • Touch, tablet, and Apple Pencil native (Pointer Events API)
    • Core has zero framework dependencies, tree-shakeable ESM + CJS
    • Fog of war with tile-based CRDT sync, undo/redo integration, and solid/procedural rendering
    • Square and hex grid overlays with snapping (D&D combat maps, alignment)
    • AoE spell templates (circle / cone / line / square) with hex-cell queries
    • Distance measurement with ruler overlays and shared presence
    • Grid constraint service for snap-to-grid tool integration

    Core provides a plugin architecture for domain-specific packages. Register custom element types, viewport plugins, render hooks, constraint services, and sync plugins — all through typed, versioned extension points.

    import { getDefaultElementRegistry } from '@fieldnotes/core';
    import type {
    ElementTypeDefinition,
    ExtensionElementEnvelope,
    BaseElement,
    } from '@fieldnotes/core';

    // Define a custom element type
    interface MarkerElement extends BaseElement {
    readonly data: { label: string; color: string; size: { w: number; h: number } };
    }

    const markerDefinition: ElementTypeDefinition<MarkerElement> = {
    type: 'my-app:marker',
    validateData: (data) => typeof data['label'] === 'string' && typeof data['color'] === 'string',
    unwrap: (el) => ({ ...el, data: el.data as MarkerElement['data'] }),
    wrap: (el) => ({
    ...el,
    type: 'extension',
    extensionType: 'my-app:marker',
    data: el.data as Record<string, unknown>,
    }),
    bounds: (el) => ({ x: el.position.x, y: el.position.y, w: el.data.size.w, h: el.data.size.h }),
    hitTest: (el, point) => {
    const b = markerDefinition.bounds(el)!;
    return point.x >= b.x && point.y >= b.y && point.x <= b.x + b.w && point.y <= b.y + b.h;
    },
    render: (ctx, el) => {
    ctx.fillStyle = el.data.color;
    ctx.beginPath();
    ctx.arc(el.position.x, el.position.y, el.data.size.w / 2, 0, Math.PI * 2);
    ctx.fill();
    },
    legacyTypes: [],
    decodeLegacy: (raw) => raw as unknown as MarkerElement,
    };

    // Register with the default registry
    const registry = getDefaultElementRegistry();
    const markerKey = registry.register(markerDefinition);
    import { Viewport, createServiceKey } from '@fieldnotes/core';
    import type { ViewportPlugin } from '@fieldnotes/core';

    // Create a viewport plugin with a typed service
    const CounterKey = createServiceKey<{ count: number }>('my-app:counter');

    const counterPlugin: ViewportPlugin = {
    name: 'counter',
    configure(ctx) {
    // Register element types, tools, and render hooks here
    },
    start(ctx) {
    let count = 0;
    ctx.registerService(CounterKey, {
    get count() {
    return count;
    },
    });
    ctx.store.on('add', () => {
    count++;
    });
    return {
    dispose() {
    /* cleanup */
    },
    };
    },
    };

    // Install plugins when creating a viewport
    const viewport = new Viewport(container, { plugins: [counterPlugin] });

    See Extending Field Notes for the full extension API, and @fieldnotes/vtt for a production-grade domain package built on these primitives. The examples/ directory contains runnable reference applications.

    pnpm install          # install dependencies
    pnpm build # build all packages
    pnpm dev # dev playground (demo) on http://localhost:5173
    pnpm dev:playground # showcase app on http://localhost:5174
    pnpm test # run all tests
    pnpm bench # run performance benchmarks
    pnpm docs:api # TypeDoc API reference into dist/api (run after pnpm build); deployed with the site at /api/ on push to master

    Example applications are in examples/:

    cd examples/react-app && pnpm dev    # React integration example
    cd examples/vue && pnpm dev # Vue integration example
    cd examples/svelte && pnpm dev # Svelte integration example
    cd examples/angular && pnpm dev # Angular integration example
    cd examples/live-play && pnpm dev # Real-time collaboration example

    Hybrid rendering: Canvas API for strokes/shapes/arrows, DOM for notes/images/HTML embeds. Shared camera and paint-stack systems keep both renderers synchronized and correctly interleaved by layer and index. See PROJECT.md for full architecture details.

    MIT