SDK
Documents as a library
The same primitives the app is built on, importable. Construct docs, snapshot them, migrate legacy content, and export — headless.
sdk.ts
ts
import {
createSeededBlockDoc, // deterministic CRDT seed
encodeBlockDoc, // doc → JSON snapshot
decodeBlockDoc, // snapshot → doc
migrateLegacyBlocks, // legacy blocks → current model
blocksToHtml,
blocksToMarkdown,
} from '@book.dev/ui';
const doc = createSeededBlockDoc([
{type: 'heading', text: 'Hello', props: {level: 1}},
{type: 'paragraph', text: 'Built in code.'},
]);
const snapshot = encodeBlockDoc(doc); // persist or ship over the wire