slateToTemplate
From @slate-serializers/template. Renders each top-level Slate node to either a string of HTML (via the same pipeline as slateToHtml) or a custom value from your configuration. Framework-agnostic: custom serializers can return React/Vue/Astro nodes or any value your app knows how to mount.
- Default config: packages/template/src/lib/config/default.ts
- Payload CMS: packages/template/src/lib/config/payload.ts
Basic usage
Without custom serializers, each block becomes an HTML string (same idea as serializing one top-level node at a time with slateToHtml).
customElementSerializers
Map a Slate type to a function that returns a non-HTML value (for example JSX). Unmapped types fall back to slateToHtml([node], config) for that node.
Custom serializers may return a string, JSX, or another value your app knows how to render from the resulting array.
Relationship to other packages
- slateToHtml — always produces an HTML string for the whole document.
- SlateToReact — React component output: flat
configwith the same keys asslateToHtml, pluselementTransforms. - slateToTemplate — one output slot per top-level node; mix HTML strings and custom outputs.