Sanity Library Reference Docs
    Preparing search index...

    Interface SanityInstance

    Represents a Sanity.io resource instance with its own configuration and lifecycle

    Instances form a hierarchy through parent/child relationships

    interface SanityInstance {
        config: SanityConfig;
        instanceId: string;
        createChild(config: SanityConfig): SanityInstance;
        dispose(): void;
        getParent(): undefined | SanityInstance;
        isDisposed(): boolean;
        match(targetConfig: Partial<SanityConfig>): undefined | SanityInstance;
        onDispose(cb: () => void): () => void;
    }
    Index

    Properties

    config: SanityConfig

    Resolved configuration for this instance

    Merges values from parent instances where appropriate

    instanceId: string

    Unique identifier for this instance

    Generated using crypto.randomUUID()

    Methods

    • Disposes the instance and cleans up associated resources

      Returns void

      Triggers all registered onDispose callbacks

    • Traverses the instance hierarchy to find the first instance whose configuration matches the given target config using a shallow comparison.

      Parameters

      • targetConfig: Partial<SanityConfig>

        A partial configuration object containing key-value pairs to match.

      Returns undefined | SanityInstance

      The first matching instance or undefined if no match is found.

    • Registers a callback to be invoked when the instance is disposed

      Parameters

      • cb: () => void

        Callback to execute on disposal

      Returns () => void

      Function to unsubscribe the callback