Skip to main content

useResolvedMediaType

Hook for resolving the media type and URL of a given URI.

import { useResolvedMediaType } from "@thirdweb-dev/react";

Usage

Provide the URI of the media asset as the argument.

import { useResolvedMediaType } from "@thirdweb-dev/react";

function App() {
const { url, mimeType } = useResolvedMediaType("https://example.com/image.jpg");

return <img src={url} type={mimeType} />;
}

Configuration

uri

The uri argument must be a valid URL or file path.

It will be resolved to the appropriate media type and URL for use in the <img> tag.

import { useResolvedMediaType } from "@thirdweb-dev/react";

function App() {
const { url, mimeType } = useResolvedMediaType("/path/to/image.jpg");

return <img src={url} type={mimeType} />;
}