Skip to main content

Overview

Excalidraw can be directly embedded as a React component in your application. This guide demonstrates how to set up and use Excalidraw with React, including advanced features like custom UI, state management, and export functionality.

Installation

1

Install dependencies

Install Excalidraw and its peer dependencies using npm or yarn:
To use unreleased changes, install @excalidraw/excalidraw@next
2

Import styles

Import the Excalidraw CSS in your component:
3

Configure asset path (optional)

For self-hosting fonts, set the asset path before rendering:
Copy fonts from node_modules/@excalidraw/excalidraw/dist/prod/fonts to your public directory.

Basic Usage

Here’s a minimal React component using Excalidraw:
App.tsx
Excalidraw takes 100% of its container’s width and height. Ensure the parent element has non-zero dimensions.

Advanced Integration

Setting up the API Reference

Access Excalidraw’s imperative API to control the editor programmatically:

Loading Initial Data

Load elements and configure the initial state:

Event Handlers

Custom UI Components

Excalidraw provides composable UI components for customization:

Export Functionality

Export drawings to various formats:

Configuration Options

Customize Excalidraw’s behavior with props:

Working with Images

Add binary files (images) to your scene:

Scene Management

Update and manipulate the scene:

Live Example

Check out the complete working example on CodeSandbox.

Next Steps

API Reference

Explore all available methods and props

Next.js Integration

Learn how to use Excalidraw with Next.js

TypeScript Types

View TypeScript type definitions

Examples

Browse more integration examples