# BYO-UI (headless) > Skip Editor.Root entirely. Use useDocumentState to drive your own UI on top of the same reducer + history timeline. Source: https://docs.docmosaic.com/docs/examples/byo-ui `useDocumentState` exposes the headless half of DocMosaic - the reducer, the history timeline, the stable action surface. No ``, no compound primitives, no opinions about your visual tree. Use it when you're building something the bundled shell doesn't fit: a custom report builder, a card composer, a minimal name-tag designer. You get the same correctness guarantees the full editor does (undo/redo, point-accurate geometry, valid PDF on export) without inheriting the shell. ## Code ```tsx 'use client'; import { useDocumentState } from '@docmosaic/react'; import { createDocument } from '@docmosaic/core'; export default function CustomEditor() { const { document, canUndo, canRedo, actions } = useDocumentState({ initialDocument: createDocument({ name: 'My custom doc' }), }); return (
actions.updateName(e.target.value)} className="border rounded px-2 py-1" />

{document.sections.length} sections across {document.pages.length} pages

); } ``` No `Editor.Root`. The hook owns the timeline; your component renders whatever UI fits. `actions` is referentially stable - safe to pass to memoised buttons. Want to mix custom UI with a few bundled primitives? Wrap your tree in `EditorProvider` with the hook's result and the primitives will read from the same state. See the [BYO-UI recipe](/docs/recipes/byo-ui-with-use-document-state) for the hybrid pattern. ## Related - [BYO-UI recipe](/docs/recipes/byo-ui-with-use-document-state) - hybrid composition - [useDocumentState reference](/docs/reference/hooks) - [Designer concept](/docs/concepts/designer) - the mental model the hook is built on