tldraw — Infinite Canvas SDK for AI Applications
Open-source infinite canvas library for building whiteboard, diagramming, and design applications. React component with real-time collaboration. Used by AI tools for visual generation. 40,000+ stars.
What it is
tldraw is an open-source infinite canvas library for building whiteboard, diagramming, and design applications. It provides a React component with drawing tools, shape primitives, text, images, and real-time collaboration out of the box.
tldraw is used by AI tools for visual generation, letting users sketch interfaces or diagrams that AI can interpret and convert to code or structured data. The library has over 40,000 GitHub stars and is used in production by multiple companies.
How it saves time or tokens
Building a canvas editor from scratch requires handling pointer events, coordinate transforms, shape rendering, undo/redo, selection, snapping, and multi-user sync. tldraw provides all of this as a single React component. Drop it into your app and you have a working canvas editor.
For AI applications, tldraw's structured shape data means you can export a user's drawing as JSON and feed it to an LLM for interpretation, reducing the need for expensive vision model calls.
How to use
- Install tldraw:
npm install tldraw
- Add the canvas to your React app:
import { Tldraw } from 'tldraw';
import 'tldraw/tldraw.css';
export default function App() {
return (
<div style={{ width: '100vw', height: '100vh' }}>
<Tldraw />
</div>
);
}
- Customize tools, shapes, and UI using tldraw's extensibility API.
- Export canvas state as JSON for processing by AI models or backend services.
Example
import { Tldraw, useEditor } from 'tldraw';
function ExportButton() {
const editor = useEditor();
const handleExport = () => {
const shapes = editor.getCurrentPageShapes();
console.log(JSON.stringify(shapes, null, 2));
};
return <button onClick={handleExport}>Export Shapes</button>;
}
function App() {
return (
<Tldraw>
<ExportButton />
</Tldraw>
);
}
Related on TokRepo
- AI Tools for Design — AI-powered design and visual generation tools
- AI Tools for Coding — Tools that convert visual designs to code
Common pitfalls
- Not importing the CSS file. tldraw requires
tldraw/tldraw.cssfor proper rendering. Without it, the canvas renders but tools and menus are unstyled. - Treating tldraw as a vector graphics editor. It is a canvas SDK for building custom editors, not a replacement for Figma or Illustrator. Use the extensibility API to build the editor your users need.
- Ignoring performance with large shape counts. Canvases with thousands of shapes may need viewport culling and pagination strategies.
- Failing to review community discussions and changelogs before upgrading. Breaking changes in major versions can disrupt existing workflows. Pin versions in production and test upgrades in staging first.
Frequently Asked Questions
tldraw is used for building whiteboard applications, diagramming tools, visual collaboration platforms, and AI-powered design tools. It provides the canvas rendering, shape management, and interaction handling so you can focus on your application logic.
tldraw exports canvas state as structured JSON. AI applications can read this JSON to interpret user drawings, convert sketches to code, or generate design suggestions. Some AI tools use tldraw as an input canvas where users sketch UI mockups that an LLM converts to working code.
Yes. tldraw includes built-in support for real-time collaboration using WebSocket sync. Multiple users can draw on the same canvas simultaneously with live cursor and selection visibility.
Yes. tldraw has an extensibility API for creating custom shapes, tools, and UI components. You can add domain-specific shapes (like flowchart nodes or UML elements) and custom interaction behaviors while keeping the core canvas functionality.
tldraw uses a dual license. The core library is open-source, but commercial use may require a license depending on your deployment model. Check the tldraw license terms for your specific use case.
Citations (3)
- tldraw GitHub— tldraw is an open-source infinite canvas library with 40,000+ GitHub stars
- tldraw Documentation— tldraw documentation and API reference
- React Documentation— React component architecture for canvas applications
Related on TokRepo
Source & Thanks
Discussion
Related Assets
Conda — Cross-Platform Package and Environment Manager
Install, update, and manage packages and isolated environments for Python, R, C/C++, and hundreds of other languages from a single tool.
Sphinx — Python Documentation Generator
Generate professional documentation from reStructuredText and Markdown with cross-references, API autodoc, and multiple output formats.
Neutralinojs — Lightweight Cross-Platform Desktop Apps
Build desktop applications with HTML, CSS, and JavaScript using a tiny native runtime instead of bundling Chromium.