Sanity Library Reference Docs
    Preparing search index...

    Interface ResourceHandle<TDataset, TProjectId>

    React SDK resource handle — extends the core DatasetHandle with resourceName for context-based resource resolution.

    Use this (or its subtypes) as the options type for custom hooks that need to accept a resource. It accepts a resource object, a resourceName registered via the resources prop on <SanityApp>, or a bare projectId/dataset pair for backward compatibility.

    interface ResourceHandle<
        TDataset extends string = string,
        TProjectId extends string = string,
    > {
        dataset?: TDataset;
        perspective?: ReleasePerspective | ClientPerspective$1;
        projectId?: TProjectId;
        resource?: DocumentResource;
        resourceName?: string;
    }

    Type Parameters

    • TDataset extends string = string
    • TProjectId extends string = string

    Hierarchy (View Summary)

    Index

    Properties

    dataset?: TDataset
    perspective?: ReleasePerspective | ClientPerspective$1
    projectId?: TProjectId
    resource?: DocumentResource

    Explicit resource to use. On an individual operation this overrides any default; on a SanityConfig it becomes the instance's default resource. Unlike projectId/dataset, this can also be a media library or canvas resource.

    resourceName?: string

    Name of a resource registered via the resources prop on <SanityApp>. Resolved to a DocumentResource at the React layer.