useStorageUpload() function
Hook used to upload any files or JSON data to decentralized storage systems like IPFS, using the storageInterface
configured on the ThirdwebProvider
Example
import { useStorageUpload } from "@thirdweb-dev/react";
export default function Component() {
const { mutateAsync: upload, isLoading } = useStorageUpload();
async function uploadData() {
const filesToUpload = [...];
const uris = await upload({ data: files });
console.log(uris);
}
return (
<button onClick={uploadData}>
Upload
</button>
)
}
Signature:
export declare function useStorageUpload<
T extends UploadOptions = IpfsUploadBatchOptions,
>(
uploadOptions?: T,
): import("@tanstack/react-query").UseMutationResult<
string[],
unknown,
StorageUploadOptions<T>,
unknown
>;
Parameters
Parameter | Type | Description |
---|---|---|
uploadOptions | T | (Optional) |
Returns:
import("@tanstack/react-query").UseMutationResult<string[], unknown, StorageUploadOptions<T>, unknown>
Function used to upload files or JSON to decentralized storage systems