> ## Documentation Index
> Fetch the complete documentation index at: https://docs.crossmint.com/llms.txt
> Use this file to discover all available pages before exploring further.

# Hosted Checkout

> Accept payments in under 5 min by just adding a button to your frontend

![Hosted Checkout Demo](https://mintcdn.com/crossmint/QK6rWfcUCMmvIQPT/images/payments/pay-button-v3/quickstart/hello-world.png?fit=max\&auto=format\&n=QK6rWfcUCMmvIQPT\&q=85\&s=e342b7faad38fff50b949787e3d5a320)

## Introduction

In this guide, you will create a web app with Next.js which allows customers to buy digital assets with credit card and
crypto payments using Crossmint's hosted checkout. You will add a button that opens a checkout hosted in a pop-up or new
tab.

<Snippet file="embedded-checkout-v3-prereqs.mdx" />

<Snippet file="payments-setup.mdx" />

### Basic Integration

This quickstart guide focuses on NFT Collections/Drops (primary sales), but Crossmint also supports marketplace integrations.

**1. Add environment variables**

Create `.env.local` in your project root:

```sh theme={null}
NEXT_PUBLIC_CROSSMINT_CLIENT_API_KEY="_YOUR_CLIENT_API_KEY_"    # From API Keys page
NEXT_PUBLIC_COLLECTION_ID="_YOUR_COLLECTION_ID_"      # From Collection details page
```

**2. Create the checkout page**

Create `/src/app/page.tsx` with:

```tsx theme={null}
"use client";

import { CrossmintProvider, CrossmintHostedCheckout } from "@crossmint/client-sdk-react-ui";

export default function Home() {
    const clientApiKey = process.env.NEXT_PUBLIC_CROSSMINT_CLIENT_API_KEY as string;
    const collectionId = process.env.NEXT_PUBLIC_COLLECTION_ID as string;

    return (
        <CrossmintProvider apiKey={clientApiKey}>
            <CrossmintHostedCheckout
                lineItems={{
                    collectionLocator: `crossmint:${collectionId}`,
                    callData: {
                        totalPrice: "0.001",
                        quantity: 1,
                    },
                }}
                payment={{
                    crypto: { enabled: true },
                    fiat: { enabled: true },
                }}
            />
        </CrossmintProvider>
    );
}
```

**3. Run your app**

<Snippet file="run-your-app.mdx" />

### (Optional) Advanced Integration

Need purchase tracking, multiple line items, or more customization? Here's a complete setup with additional features:

> [tab] For NFT Collections/Drops
>
> ```tsx theme={null}
> "use client";
>
> import { useEffect } from "react";
> import {
>     CrossmintProvider,
>     CrossmintCheckoutProvider,
>     CrossmintHostedCheckout,
>     useCrossmintCheckout,
> } from "@crossmint/client-sdk-react-ui";
>
> // Component with purchase tracking
> function 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 (
>         <CrossmintHostedCheckout
>             lineItems={[
>                 {
>                     collectionLocator: `crossmint:${collectionId}`,
>                     callData: {
>                         totalPrice: "0.001",
>                         quantity: 1,
>                     },
>                 },
>                 {
>                     collectionLocator: `crossmint:${collectionId}`,
>                     callData: {
>                         totalPrice: "0.002",
>                         quantity: 2,
>                     },
>                 },
>         ]}
>         appearance={{
>             display: "new-tab", // Open in a new tab
>             overlay: {
>                 enabled: false, // Disable overlay
>             },
>             theme: {
>                 button: "dark", // Dark button theme
>                 checkout: "dark", // Dark checkout theme
>             },
>         }}
>         payment={{
>             crypto: {
>                 enabled: true,
>                 defaultChain: "polygon", // Set preferred blockchain
>                 defaultCurrency: "usdc", // Set preferred crypto
>             },
>             fiat: {
>                 enabled: true,
>                 defaultCurrency: "usd", // Set preferred fiat currency
>             },
>             receiptEmail: "receipt@example.com", // Optional: Set receipt email
>         }}
>         recipient={{
>             email: "buyer@example.com", // Digital assets will be delivered to this email's wallet
>             // Or use walletAddress: "0x..." for direct delivery
>         }}
>         locale="en-US" // Set interface language
>     />
> );
>
> }
>
> // Main component with providers
> export default function Home() {
>     const clientApiKey = process.env.NEXT_PUBLIC_CROSSMINT_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>
>     );
> }
> ```

> [tab] For Marketplaces
>
> ```tsx theme={null}
> "use client";
>
> import { useEffect } from "react";
> import {
>     CrossmintProvider,
>     CrossmintCheckoutProvider,
>     CrossmintHostedCheckout,
>     useCrossmintCheckout,
> } from "@crossmint/client-sdk-react-ui";
>
> // Component with purchase tracking
> function Checkout() {
>     const { order } = useCrossmintCheckout();
>
>     useEffect(() => {
>         if (order && order.phase === "completed") {
>             console.log("Purchase completed!");
>             // Handle successful purchase
>         }
>     }, [order]);
>
>     return (
>         <CrossmintHostedCheckout
>             lineItems={[
>                 {
>                     // For Solana NFTs
>                     tokenLocator: "solana:4oDd...x6NC",
>                     callData: {
>                         totalPrice: "0.1",
>                         buyerCreatorRoyaltyPercent: 100
>                     }
>                 },
>                 {
>                     // For EVM NFTs (Ethereum, Polygon, etc)
>                     tokenLocator: "ethereum:0xbC...307e:7777",
>                     callData: {
>                         totalPrice: "0.2"
>                     }
>                 }
>             ]}
>             appearance={{
>                 display: "new-tab", // Open in a new tab
>                 overlay: {
>                     enabled: false, // Disable overlay
>                 },
>                 theme: {
>                     button: "dark", // Dark button theme
>                     checkout: "dark", // Dark checkout theme
>                 },
>             }}
>             payment={{
>                 crypto: {
>                     enabled: true,
>                     defaultChain: "solana", // Set preferred blockchain
>                     defaultCurrency: "usdc", // Set preferred crypto
>                 },
>                 fiat: {
>                     enabled: true,
>                     defaultCurrency: "usd", // Set preferred fiat currency
>                 },
>             }}
>             locale="en-US" // Set interface language
>         />
>     );
> }
>
> // Main component with providers
> export default function Home() {
>     const clientApiKey = process.env.NEXT_PUBLIC_CROSSMINT_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>
>     );
> }
> ```

> [!NOTE]
>
> This advanced example showcases:
>
> * Multiple NFTs in one checkout
> * Purchase status tracking
> * Preferred payment methods and currencies
> * Email-based digital asset delivery
> * Language settings
>
> Learn more in the guides: [Payment Methods](https://docs.crossmint.com/checkout/concepts/payment-methods.md) · [Multi-purchases](https://docs.crossmint.com/checkout/guides/select-items.md#multiple-item-orders)
> · [Hooks & Events](https://docs.crossmint.com/checkout/guides/hooks-and-events.md)

### Testing Your Integration

This demo uses the staging environment:

* Use [test credit cards](https://docs.crossmint.com/checkout/advanced/testing-tips.md#test-credit-card-numbers) for payments
* Get test USDC from the [faucet](https://docs.crossmint.com/wallets/guides/fund-staging-wallet.md#option-3-use-the-faucet-web-app)
* Check [price limits](https://docs.crossmint.com/checkout/advanced/testing-tips.md#limits-in-staging) for staging

## All Set!

You've successfully integrated a hosted checkout with credit card and crypto payment methods!

![](https://mintcdn.com/crossmint/QK6rWfcUCMmvIQPT/images/payments/pay-button-v3/quickstart/demo.png?fit=max\&auto=format\&n=QK6rWfcUCMmvIQPT\&q=85\&s=b65e6f7c4ad8b3ca80658296744d8bc6)

> [!NOTE]
>
> Remember this demo is built on staging, so the digital assets will show up on the testnets. To launch on production,
> check the [production checklist](https://docs.crossmint.com/checkout/guides/production-checklist.md). You will need to contact
> [Sales](https://www.crossmint.com/contact-sales) to enable the embedded checkout on production.

## Next Steps

### Customize the UI and Behavior Further

> [card] [UI Customization](https://docs.crossmint.com/checkout/guides/appearance.md)
>
> Learn how to customize the look and feel of the checkout button

> [card] [Payment Methods](https://docs.crossmint.com/checkout/concepts/payment-methods.md)
>
> Configure available payment options for your users

> [card] [Hooks & Events](https://docs.crossmint.com/checkout/guides/hooks-and-events.md)
>
> Use hooks to build custom checkout experiences

### Advanced Topics

> [card] [SDK Reference](https://docs.crossmint.com/sdk-reference/checkout/react/components.md)

> [card] [Launch in Production](https://docs.crossmint.com/checkout/guides/production-checklist.md)

> [card] [Localization](https://docs.crossmint.com/checkout/guides/localization.md)

> [card] [Multi-purchases](https://docs.crossmint.com/checkout/guides/select-items.md#multiple-item-orders)

> [card] [Marketplaces](https://docs.crossmint.com/checkout/advanced/marketplaces-and-launchpads.md)

> [card] [Testing Tips](https://docs.crossmint.com/checkout/advanced/testing-tips.md)
