@drawio/react
Product · Developer tool by draw.io
Professional diagramming for your React applications.建设
@drawio/react is an open-source React component that embeds the professional draw.io diagram editor into web applications. It provides developers with a typed, secure way to integrate diagramming, supporting Next.js, self-hosting, and multiple export formats.建设
- Price
- From 0 USD
- Languages
- English
Category: Developer Tools
- Package Name建设
- @drawio/react建设
- License建设
- Apache 2.0建设
- Supported Frameworks建设
- React, Next.js, Vue, Angular, Svelte建设
- Export Formats建设
- PNG, SVG, xmlsvg, JSON, HTML建设
- Input Formats建设
- XML, Mermaid, PlantUML, CSV建设
- React component for embedding the draw.io editor建设
- Apache 2.0 licensed open-source package建设
- Full TypeScript support for events and methods建设
- Supports Next.js and Server-Side Rendering建设
- Exports to PNG, SVG, and editable SVG formats建设
Overview
@drawio/react is an open-source developer tool that provides a dedicated React component for embedding the draw.io diagram editor into web applications. It simplifies the integration process by handling the complex iframe communication protocol and providing typed events and methods for React and Next.js environments. Developers can use it to build custom wikis, documentation tools, or internal platforms that require professional diagramming capabilities without managing an external editor. The component supports loading and saving diagrams in XML, PNG, and SVG formats, and it allows for complete UI customization through URL parameters. It is designed with a security-first approach, ensuring that diagram data is sent only to the specified editor origin and can be self-hosted via Docker.建设
Integration and Development
- Typed Protocol: The package includes TypeScript types for every action and event in the embed protocol, ensuring safer development.
- Next.js and SSR Support: The component is marked as a client component, allowing it to render the iframe on the server while starting the editor in the browser during hydration.
Diagram Handling and Storage
- Multiple Export Formats: The export() method returns diagrams as PNG, SVG, editable SVG (xmlsvg), JSON, or HTML data URIs.
- Editable SVG Images: The component can store diagrams as SVG images with the diagram data embedded inside, allowing any page to show the image while remaining editable.
- Code-to-Diagram Conversion: Developers can convert Mermaid, PlantUML, or CSV data into diagrams by passing a descriptor prop to the component.
- Autosave and Local Storage: The component supports an autosave prop that triggers a callback after every change, which can be used to store edits in local storage or a backend.
Security and Configuration建设
- Self-hosting Support建设: Developers can set a baseUrl to load the editor from their own server, such as a self-hosted draw.io Docker image.
- UI Customization: The component supports URL parameters to customize the editor's appearance, including dark mode, language, and UI themes.
Use cases
- Developers embed the draw.io editor into internal wikis to allow teams to create and edit technical documentation.建设
- Software teams use the component to convert Mermaid or PlantUML code into editable visual diagrams within their own apps.建设
- Product managers integrate the editor into project management tools to store editable SVG diagrams directly in task descriptions.建设
Specifications
- Package Name建设
- @drawio/react建设
- License建设
- Apache 2.0建设
- Supported Frameworks建设
- React, Next.js, Vue, Angular, Svelte建设
- Export Formats建设
- PNG, SVG, xmlsvg, JSON, HTML建设
- Input Formats建设
- XML, Mermaid, PlantUML, CSV建设
How it works
- Install the Package建设: Install the @drawio/react package using npm or another package manager.建设
- Add the Component建设: Add the DrawioEditor component to a React or Next.js component and specify a container height.建设
- Handle Data Storage建设: Implement the onSave or onAutosave props to receive the diagram XML and store it in your application's database or local storage.建设
Pricing
- Open Source建设
- Free建设
FAQ
Why does the editor show a 403 error?建设
The editor shows a 403 error if the host page is on a non-standard port or in a headless browser; this is resolved by self-hosting the editor using the jgraph/drawio Docker image.建设
Does it support Next.js Server-Side Rendering?建设
The component is marked as a client component, so it renders the iframe on the server and starts the editor in the browser, ensuring no messages are lost during hydration.建设
Can I use a self-hosted version of draw.io?建设
Yes, by setting the baseUrl prop, you can load the editor from your own server or a local Docker container instead of the default cloud address.建设
How do I export diagrams from the component?建设
The export() method returns a promise that resolves to a data URI for formats including PNG, SVG, and editable SVG.建设,question
Added by AntSpace from public sources (drawio.com).