# BYO-UI with useDocumentState > Skip Editor.Root entirely and build your own UI on top of the headless state hook. Source: https://docs.docmosaic.com/docs/recipes/byo-ui-with-use-document-state `useDocumentState` is the headless ("bring your own UI") hook. Same reducer, same history timeline, no compound primitives. Use it when you want full control over the visual surface. ## The hook ```ts import { useDocumentState } from '@docmosaic/react'; import { createDocument } from '@docmosaic/core'; const { document, formattedDate, canUndo, canRedo, actions } = useDocumentState({ initialDocument: createDocument(), }); ``` It returns: - **`document`** - the current snapshot. Re-renders on every change. - **`formattedDate`** - `updatedAt` formatted for display. - **`canUndo` / `canRedo`** - booleans for button enabled states. - **`actions`** - a stable, referentially-equal object of dispatcher functions. ## A minimal custom editor ```tsx 'use client'; import { useDocumentState } from '@docmosaic/react'; import { createDocument } from '@docmosaic/core'; export function CustomEditor() { const { document, canUndo, canRedo, actions } = useDocumentState({ initialDocument: createDocument(), }); return (
{document.sections.length} sections across {document.pages.length} pages