Skip to main content

useNFTCollection() function

Hook for getting an instance of an NFTCollection contract. This contract is meant to interface with ERC721 compliant NFTs.

Example

import { useNFTCollection } from '@thirdweb-dev/react'

export default function Component() {
const nftCollection = useNFTCollection("<YOUR-CONTRACT-ADDRESS>")

// Now you can use the nftCollection contract in the rest of the component

// For example, this function will return all the NFTs on this contract
async function getNFTs() {
const nfts = await nftCollection.getAll()
return nfts
}

...
}

Signature:

export declare function useNFTCollection(
contractAddress?: string,
): NFTCollection | undefined;

Parameters

ParameterTypeDescription
contractAddressstring(Optional) the address of the NFT Collection contract, found in your thirdweb dashboard

Returns:

NFTCollection | undefined