<a download>, URL.createObjectURL) are blocked. useDownload hands the host one or more resources to write to the user’s device, so a view can save a file it produced.
Example
The view builds a CSV from the carousel’s products and hands the host an inline resource, then offers a server-hosted PDF as a resource link.views/carousel.tsx
Returns
useDownload returns a single function.
download
params. The promise resolves once the host responds, and rejects if the request times out or the connection is lost.
params one or more resources to save, each carried inline or fetched by the host from a URL.
EmbeddedResource carries the file inline; resource holds the bytes as a UTF-8 text string or a base64 blob. The uri’s last segment sets the suggested filename.
ResourceLink points the host at a URL it fetches itself.
DownloadResult:
isError is true when the download did not happen: the user cancelled, or the host denied it (including a host that lacks the download capability). It is absent or false on success. A request that fails to complete (timeout, lost connection) rejects the promise instead of setting this flag.
Handle Files
Move files in and out of your app
useFiles
Upload and resolve host-managed files
useOpenExternal
Open a link outside the view