useStorage
Get the instance of the ThirdwebStorage
class being used by the ThirdwebProvider
.
Allows you to use the TypeScript SDK functionality of Storage in your React app.
API Key
You will require an API key to use thirdweb’s storage services with the SDK. If you haven’t created a key yet you can do so for free from the thirdweb dashboard.
You can then obtain a clientId
from the API key which you will need to pass to the ThirdwebProvider
component:
import { ThirdwebProvider } from "@thirdweb/react";
const App = () => {
return (
<ThirdwebProvider clientId="YOUR_CLIENT_ID">
<YourApp />
</ThirdwebProvider>
);
};
Configurable in the storageInterface
prop of the ThirdwebProvider
.
The hook returns a ThirdwebStorage
instance. View the TypeScript Storage documentation for more information.
import { useStorage } from "@thirdweb/react";
Usage
import { useStorage } from "@thirdweb-dev/react";
export default function Component() {
const storage = useStorage();
// Now you can use the functionality of the ThirdwebStorage class:
storage?.download(); // Download a file from IPFS
storage?.upload(); // Upload a file to IPFS
}