@mocanvas/mocanvas · function

useImageOrVideoAsset

declare function useImageOrVideoAsset({ assetId, width, shouldResolveToOriginal }: UseImageOrVideoAssetOptions): {
    asset: Asset | null;
    url: string | null;
    isPlaceholder: boolean;
}

Resolve an image or video asset to a URL that can be put in a src.

Asynchronous because editor.resolveAssetUrl may have to ask an asset store — the seam a host uses to sign a URL or to serve a downscaled variant. The hook reports isPlaceholder until the answer arrives, so a shape can draw a grey box rather than a broken image.

mocanvas is built by Symbio. Free for non-commercial, non-profit and development use; commercial use needs an agreement. Not affiliated with or endorsed by tldraw.