Installation
Lexical is published as multiple npm packages under the@lexical scope. This guide covers installation for different use cases.
Package Managers
Install Lexical using your preferred package manager:The
lexical package contains the core framework, while @lexical/react provides React-specific bindings and components.Core Packages
lexical
The core Lexical framework - required for all projects.- Core editor (
createEditor) - Base node types (TextNode, ElementNode, DecoratorNode)
- Selection management
- Update and read APIs
- Command system
- Event listeners
@lexical/react
React bindings and components for Lexical.LexicalComposer- Root context providerContentEditable- Editable content component- Plugin components (PlainTextPlugin, RichTextPlugin, etc.)
- React hooks for editor access
- Error boundary component
Feature Packages
Lexical provides modular feature packages for extended functionality:Rich Text Editing
- Headings (H1-H6)
- Block quotes
- Text formatting (bold, italic, underline, strikethrough)
- Code blocks
Lists
- Ordered lists
- Unordered lists
- Checklist/todo lists
- Nested lists
Links
- Link nodes
- Auto-link detection
- Link editing utilities
Tables
- Table creation and editing
- Cell merging
- Table navigation
- Resize functionality
Code Highlighting
- Syntax highlighting
- Multiple language support
- Code block formatting
Markdown
- Markdown import/export
- Markdown shortcuts (typing
#for heading,*for italic, etc.) - CommonMark and GitHub Flavored Markdown
HTML Serialization
- HTML import/export
- DOM serialization
- Custom HTML handling
History (Undo/Redo)
- Undo/redo functionality
- History state management
- Custom merge tags
Collaboration
- Real-time collaboration
- Yjs CRDT integration
- Multi-user editing
- Conflict resolution
Utility Packages
Additional utilities for common tasks:@lexical/utils
- Helper functions for common operations
- Node traversal utilities
- Selection utilities
- Register merging (
mergeRegister)
@lexical/headless
- Headless editor for server-side rendering
- Testing utilities
- Non-DOM environments
TypeScript Support
Lexical is written in TypeScript and includes type definitions out of the box. No additional@types packages are needed.
CDN Usage
For quick prototyping, you can use Lexical via CDN (not recommended for production):Version Compatibility
All@lexical/* packages should be kept at the same version to ensure compatibility:
Mixing different versions of Lexical packages may cause runtime errors and unexpected behavior.
Common Installation Patterns
Minimal React Setup
For a basic plain text editor:Standard Rich Text Editor
For a typical rich text editor with common features:Full-Featured Editor
For a comprehensive editor with all features:Collaborative Editor
For real-time collaboration:Next Steps
Quickstart Guide
Build your first editor with step-by-step instructions
Browser Support
Check which browsers are supported by Lexical
React Integration
Learn about React-specific features and components
Core Concepts
Understand Lexical’s architecture