--- title: Quick start status: published author: steveruizok date: 3/22/2023 order: 0 keywords: - hello world - intro - start - installation --- Have five minutes? Run this command in your terminal to explore tldraw [starter kits](/starter-kits): ```bash npm create tldraw@latest ``` Have a little more time? Let's try out the tldraw SDK in a React project. If you're new to React, we recommend using a [Vite template](https://vitejs.dev/guide/#scaffolding-your-first-vite-project) as a starter. We'll assume your project is already running locally. ## Getting started First, install the `tldraw` package from npm: ```bash npm install tldraw ``` Next, in your React project, import the `Tldraw` component and tldraw's CSS styles. Then render the `Tldraw` component inside a full screen container: ```tsx import { Tldraw } from 'tldraw' import 'tldraw/tldraw.css' export default function App() { return (
) } ``` That's pretty much it! At this point, you should have a complete working single-user canvas. You can draw, write, add images and video, zoom, pan, copy and paste, undo and redo—everything you'd expect from a canvas. You'll be starting from our default [shapes](/docs/shapes), [tools](/docs/tools), and [user interface](/docs/user-interface), but you can customize all of these things for your project if you wish. For now, let's show off a few more features. ## Local persistence Let's add local persistence by passing a `persistenceKey` prop to the `Tldraw` component: ```tsx export default function App() { return (
) } ```
The `persistenceKey` prop saves your project to the browser's storage so that it survives a refresh. It also synchronizes the project with other instances that share the same key—even in other browser tabs! Give it a try by opening your app in a second window. ## Real-time collaboration To add support for multiple users collaborating in real time, you can use the [**tldraw sync**](/docs/sync) library. Its demo hook connects your app to tldraw's demo server, which hosts temporary rooms. First, install the `@tldraw/sync` package: ```bash npm install @tldraw/sync ``` Next, import the `useSyncDemo` hook from the `@tldraw/sync` package. Call it in your component with a unique ID and pass the store that it returns to the `Tldraw` component: ```tsx import { Tldraw } from 'tldraw' import { useSyncDemo } from '@tldraw/sync' import 'tldraw/tldraw.css' export default function App() { const store = useSyncDemo({ roomId: 'insert-any-string-here' }) return (
) } ```
Try it out by opening your project in a second incognito window, or else access it from another device. You should see all of tldraw's multiplayer features: live cursors, user names, viewport following, cursor chat, and more. If you want to go further with real-time collaboration, be sure to check out our guide to the [**tldraw sync**](/docs/sync) library. ## Controlling the canvas The tldraw [editor](/docs/editor) has a runtime JavaScript API. Everything that can happen in tldraw can be done programmatically through the [Editor](?) instance. For simplicity's sake, let's roll back our persistence and sync code. We can then use the `Tldraw` component's `onMount` callback to get access to the Editor instance. We'll use the editor to create a new shape on the canvas, select it, then slowly zoom to it. ```tsx import { Editor, Tldraw, toRichText } from 'tldraw' import 'tldraw/tldraw.css' export default function App() { const handleMount = (editor: Editor) => { editor.createShape({ type: 'text', x: 200, y: 200, props: { richText: toRichText('Hello world!'), }, }) editor.selectAll() editor.zoomToSelection({ animation: { duration: 5000 }, }) } return (
) } ``` The Editor is tldraw's main interface for controlling the canvas. Be sure to check out the [Editor](?) API documentation for more information on what you can do with it, as well as our [guide on using the editor](/docs/editor). ## Next steps Now that you've seen how the tldraw canvas works, you can: - Create your own [shapes](/docs/shapes) and [tools](/docs/tools) - Customize the [user interface](/docs/user-interface) - Learn more about the [editor](/docs/editor) - Explore our [examples](/examples) - Build with our [starter kits](/starter-kits) The SDK lets you customize shapes, tools, UI, and more. In addition to our long-form docs, we have dozens of examples in our [examples section](/examples) that cover more of its functionality. You can run these locally with the tldraw [GitHub repository](https://github.com/tldraw/tldraw). ## Join our community If you build something great, please share it with us in our [#show-and-tell](https://discord.tldraw.com/?utm_source=docs&utm_medium=organic&utm_campaign=sociallink) channel on Discord. Good luck!