useMintNFT
Hook for minting a new NFT on a smart contract.
Available to use on smart contracts that implement the ERC721 or ERC1155 standard.
By default, the process uploads and pins the NFT metadata to IPFS before minting.
import { useMintNFT } from "@thirdweb-dev/react";
const { mutateAsync, isLoading, error } = useMintNFT(contract);
Usage
Provide your NFT collection contract as the argument.
import { useMintNFT, useContract, Web3Button } from "@thirdweb-dev/react";
// Your smart contract address
const contractAddress = "{{contract_address}}";
function App() {
const { contract } = useContract(contractAddress);
const { mutateAsync: mintNft, isLoading, error } = useMintNFT(contract);
return (
<Web3Button
contractAddress={contractAddress}
action={() =>
mintNft({
metadata: {
name: "My NFT",
description: "This is my NFT",
image: "ipfs://example.com/my-nft.png", // Accepts any URL or File type
},
to: "{{wallet_address}}", // Use useAddress hook to get current wallet address
})
}
>
Mint NFT
</Web3Button>
);
}