DocumentRecordType

See source code

Record type definition for TLDocument with validation and default properties. Configures the document as a document-scoped record that persists across sessions.

DocumentRecordType: import("@tldraw/store").RecordType<TLDocument, never>;

Example

// Create a document record (usually done automatically)
const documentRecord = DocumentRecordType.create({
  id: TLDOCUMENT_ID,
  name: "My Drawing",
  gridSize: 20,
  meta: { createdAt: Date.now() },
});

// Create with defaults
const defaultDocument = DocumentRecordType.create({
  id: TLDOCUMENT_ID,
  // gridSize: 10, name: '', meta: {} are applied as defaults
});

// Store the document
store.put([documentRecord]);
Prev
DefaultVerticalAlignStyle
Next
drawShapeMigrations