Skip to main content

useResolvedMediaType() function

Example

Usage with fully formed url:

const Component = () => {
const resolved = useResolvedMediaType("https://example.com/video.mp4");
console.log("mime type", resolved.data.mimeType);
console.log("url", resolved.data.url);
return null;
};

Usage with ipfs cid:

const Component = () => {
const resolved = useResolvedMediaType(
"ipfs://QmWATWQ7fVPP2EFGu71UkfnqhYXDYH566qy47CnJDgvsd",
);
console.log("mime type", resolved.data.mimeType);
console.log("url", resolved.data.url);
return null;
};

Signature:

export declare function useResolvedMediaType(uri?: string): {
url: string | undefined;
mimeType: string | undefined;
};

Parameters

ParameterTypeDescription
uristring(Optional) the uri to resolve (can be a url or a ipfs://<cid>)

Returns:

{ url: string | undefined; mimeType: string | undefined; }

the fully resolved url + mime type of the media