Sanity App SDK
    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

    • Creates a child instance with merged configuration

      Parameters

      • config: SanityConfig

        Configuration to merge with parent values

      Returns SanityInstance

      Child instances inherit parent configuration but can override values

    • Disposes the instance and cleans up associated resources

      Returns void

      Triggers all registered onDispose callbacks

    • Gets the parent instance in the hierarchy

      Returns undefined | SanityInstance

      Parent instance or undefined if this is the root

    • Checks if the instance has been disposed

      Returns boolean

      true if dispose() has been called

    • 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