Create a new document, relying on Typegen for the initial-value type.
A document-type handle including documentType, an optional documentId, and optionally projectId/dataset/perspective.
A function that creates the document. It accepts optional initial field values and an optional {documentId} override,
and resolves to the DocumentHandle of the created document (carrying the generated or supplied id).
Create a new document with an explicit type TData.
A document-type handle including documentType and optionally projectId/dataset/perspective.
A function that creates the document. It accepts optional initial field values (typed against TData) and an
optional {documentId} override, and resolves to the DocumentHandle of the created document.
Provides a function to create a new document and returns its handle.
Remarks
This is the create counterpart to useEditDocument. It wraps useApplyDocumentActions and the
createDocumentaction for the common single-document case, so you don't have to assemble the action by hand.It handles the document ID for you: if you don't supply one (on the handle or via the per-call
{documentId}override), a UUID is generated. Either way the returned DocumentHandle carries that id, ready to pass to useDocument, useEditDocument, or your router.Unlike useEditDocument, this hook does not read existing document state, so it never suspends.
For atomic create-and-publish, or for creating several documents in a single transaction, use useApplyDocumentActions with the
createDocumentandpublishDocumentaction creators directly.Example: Create a document and navigate to it