React NFT Gallery
React NFT Gallery is a React component to render any Ethereum address's NFTs as a gallery.
The NFT assets for an address are resolved via the OpenSea API.
⚠️ Please note: This library is currently in beta and should not be considered stable until v1.0.0
is released.
This means:
- The gallery may see breaking changes between minor versions until
v1.0.0
is released.
- The gallery may not always render/behave as expected across different browsers & browser versions.
Please open an issue in this case.
- The gallery may not render/behave as expected for your use case.
Please open an issue in this case.
OpenSea API Key
OpenSea has recently added the requirement for an X-API-KEY
header to be passed for any non-trivial
requests to their /assets
endpoint.
By default, react-nft-gallery
can now only fetch the first 20 assets for any provided ownerAddress
.
The gallery's full capabilities are available by passing an OpenSea API key as the openseaApiKey
prop, or by using a custom API endpoint.
To request an API key, please consult the API key form on the OpenSea docs.
Installation
npm i --save react-nft-gallery
Usage
ownerAddress
is the only prop that is required out-of-the-box:
import { NftGallery } from 'react-nft-gallery';
return <NftGallery ownerAddress="vitalik.eth" />;
Using a custom API endpoint
To use a custom API endpoint, pass it via the apiUrl
prop.
If the endpoint injects an OpenSea API key, set the isProxyApi
prop to true
.
This allows for paginated requests without exposing the OpenSea API key in the client via openseaApiKey
:
import { NftGallery } from 'react-nft-gallery';
return (
<NftGallery
ownerAddress="vitalik.eth"
apiUrl="https://your-opensea-api-proxy.vercel.app"
isProxyApi={true}
/>
);
API
interface NftGalleryProps {
ownerAddress: string;
openseaApiKey?: string;
isProxyApi?: boolean;
apiUrl?: string;
autoRetry?: boolean;
metadataIsVisible?: boolean;
darkMode?: boolean;
showcaseMode?: boolean;
showcaseItemIds?: string[];
hasLightbox?: boolean;
hasExternalLinks?: boolean;
isInline?: boolean;
hasLoadMoreButton?: boolean;
galleryContainerStyle?: CSSProperties;
itemContainerStyle?: CSSProperties;
imgContainerStyle?: CSSProperties;
}
Roadmap