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: packages/template/src/lib/config/payload.ts
- Serializer implementation: packages/template/src/lib/serializers.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.
The library README shows returning a function in some examples—your custom serializer may return a string, JSX, or another renderable depending on how you consume 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.