In this guide, you will create a web app with Next.js which allows customers to buy NFTs with credit card and crypto payments, using Crossmint’s embedded checkout. Crossmint also supports payments for crypto onramp, memecoins, and other onchain assets (ERC20 tokens, ERC721 tokens, and ERC1155 tokens).If you want to get started immediately, you can clone a repo with a functioning embedded checkout here: https://github.com/Crossmint/crossmint-embedded-demo. If you want to get started step by step, continue following the guide below.
To integrate in production/mainnet, you'll also need to complete account and collection verification. More
information in the production launch guide.
For Marketplaces and Launchpads: You do not need to create a collection (skip Step 2).Simply use tokenLocator instead of collectionLocator in the examples.
It is recommended to test tokenlocator in the production environment.See Marketplaces & Launchpads guide for more secondary-sale specific details.
This guide will start from scratch with an empty Next.js application. You'll install the required @crossmint/client-sdk-react-ui dependency and add the embedded checkout component. To get started:
If you see this message, type y and press Enter to proceed:
Need to install the following packages: create-next-app@latestOk to proceed? (y)
2
Name your app `crossmint-embedded-checkout-demo` and accept the default options
What is your project named? crossmint-embedded-checkout-demoWould you like to use TypeScript? YesWould you like to use ESLint? YesWould you like to use Tailwind CSS? YesWould you like to use `src/` directory? NoWould you like to use App Router? (recommended) YesWould you like to customize the default import alias? No
3
Change into the directory created in previous steps
Need purchase tracking, multiple NFT purchases at once, or more customization? Here’s a complete setup with additional features:
"use client";import { useEffect } from "react";import { CrossmintProvider, CrossmintCheckoutProvider, CrossmintEmbeddedCheckout, useCrossmintCheckout,} from "@crossmint/client-sdk-react-ui";// Component with purchase trackingfunction Checkout() { const { order } = useCrossmintCheckout(); const collectionId = process.env.NEXT_PUBLIC_COLLECTION_ID as string; useEffect(() => { if (order && order.phase === "completed") { console.log("Purchase completed!"); // Handle successful purchase } }, [order]); return ( <CrossmintEmbeddedCheckout lineItems={[ { collectionLocator: `crossmint:${collectionId}`, callData: { totalPrice: "0.001", quantity: 1, }, }, { collectionLocator: `crossmint:${collectionId}`, callData: { totalPrice: "0.002", quantity: 2, }, }, ]} payment={{ crypto: { enabled: true, defaultChain: "polygon", // Set preferred blockchain defaultCurrency: "matic", // Set preferred crypto }, fiat: { enabled: true, defaultCurrency: "usd", // Set preferred fiat currency allowedMethods: { card: true, applePay: true, googlePay: true, }, }, receiptEmail: "receipt@example.com", // Optional: Set receipt email }} recipient={{ email: "buyer@example.com", // NFTs will be delivered to this email's wallet // Or use walletAddress: "0x..." for direct delivery }} locale="en-US" // Set interface language /> );}// Main component with providersexport default function Home() { const clientApiKey = process.env.NEXT_PUBLIC_CLIENT_API_KEY as string; return ( <div className="flex flex-col items-center justify-start min-h-screen p-6"> <CrossmintProvider apiKey={clientApiKey}> <CrossmintCheckoutProvider> <Checkout /> </CrossmintCheckoutProvider> </CrossmintProvider> </div> );}
This advanced example showcases: - Multiple NFTs in one checkout - Purchase status tracking - Preferred payment
methods and currencies - Email-based NFT delivery - Language settings Learn more in our guides: - Payment
Methods - Multi-purchases -
React Hooks
You’ve successfully integrated card and crypto payments with the Crossmint Embedded Checkout!
Remember this demo is built on staging, so the digital assets will show up on the testnets. To launch on production,
check the production launch checklist. You will need to contact
Sales to enable the embedded checkout on production.