Usage
Installation
The fastest way to enable HTML serialization is with the BaseEditorKit, which includes pre-configured base plugins that support HTML conversion for most common elements and marks.
Add Kit
import { createSlateEditor } from "platejs";
import { serializeHtml } from "platejs/static";
import { BaseEditorKit } from "@/components/editor/editor-base-kit";
const editor = createSlateEditor({
plugins: BaseEditorKit,
value: [
{ type: "h1", children: [{ text: "Hello World" }] },
{ type: "p", children: [{ text: "This content will be serialized to HTML." }] },
],
});
// Serialize to HTML
const html = await serializeHtml(editor);
Example
See a complete server-side HTML generation example:






















