fn
useObjectUrl
v0.0.14testeddemoCreate and auto-revoke an object URL for a Blob, File, or MediaSource. The previous URL is revoked whenever the source changes, and the active URL is revoked on scope dispose.
Example
ts
const file = shallowRef<File>();
const url = useObjectUrl(file);Demo
Loading demo…
Signature
ts
export function useObjectUrl(
object: MaybeRefOrGetter<Blob | MediaSource | null | undefined>,
options: UseObjectUrlOptions ={ ... }Parameters
| Parameter | Type | Description |
|---|---|---|
object | MaybeRefOrGetter<Blob | MediaSource | null | undefined> | The reactive source to create an object URL for |
options? | UseObjectUrlOptions | Options |
Returns
UseObjectUrlReturnA read-only ref holding the current object URL, or undefined when there is no source (or in unsupported/SSR environments)