Sanity Library Reference Docs
    Preparing search index...

    Interface SingletonDefinitionBeta

    Defines a singleton: a document with a fixed id that can be created exactly once.

    title and icon are used as the default list item title and icon by the singleton Structure Tool builder functions.

    initialValue provides the value of the singleton's generated initial value template.

    Each falls back to the schema type's own configuration if omitted.

    interface SingletonDefinition {
        documentId: string;
        icon?: ComponentType;
        id: string;
        initialValue?: any;
        schemaType: string;
        title?: string;
    }

    Hierarchy

    • Pick<BaseSchemaType, "title" | "icon" | "initialValue">
      • SingletonDefinition
    Index

    Properties

    documentId: string

    The singleton document id.

    Must be unique across singleton definitions.

    icon?: ComponentType
    id: string

    The singleton definition id: the stable identity by which structure code references the singleton. If omitted, it inherits the definition's documentId. Establishing a discrete id for the definition decouples the singleton's identity from its schema type and document id:

    • Multiple singletons can share a schema type if necessary.
    • Structure code (often shared across workspaces) can reference a singleton by a value that stays constant while each workspace maps it to a different document id (e.g. per-dataset or per-environment ids).
    • Developers can change documentId or schemaType over time while preserving the semantic identity of the singleton.

    Must be unique across singleton definitions.

    initialValue?: any
    schemaType: string

    The name of the document schema type used by the singleton.

    title?: string