> ## 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.

# Quickstart ⚡

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

<Frame type="simple">
  <img src="https://mintcdn.com/crossmint/QK6rWfcUCMmvIQPT/images/payments/pay-button-v3/quickstart/hello-world.png?fit=max&auto=format&n=QK6rWfcUCMmvIQPT&q=85&s=e342b7faad38fff50b949787e3d5a320" alt="Hosted Checkout Demo" width="1919" height="941" data-path="images/payments/pay-button-v3/quickstart/hello-world.png" />
</Frame>

## 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. We 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.

<Steps>
  <Step title="Add environment variables">
    Create `.env.local` in your project root:

    ```sh theme={null}
    NEXT_PUBLIC_CLIENT_API_KEY="_YOUR_CLIENT_API_KEY_"    # From API Keys page
    NEXT_PUBLIC_COLLECTION_ID="_YOUR_COLLECTION_ID_"      # From Collection details page
    ```
  </Step>

  <Step title="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_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>
        );
    }
    ```
  </Step>

  <Step title="Run your app">
    Navigate to the directory your package.json is to run the app

    ```bash theme={null}
    cd hosted-checkout/crossmint-hosted-checkout-demo
    ```

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

### (Optional) Advanced Integration

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

<Tabs>
  <Tab title="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: "matic", // 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_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>

  <Tab title="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: "sol", // 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_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>
</Tabs>

<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 our guides: - [Payment
  Methods](/payments/pay-button/guides/payment-methods) - [Multi-purchases](/payments/pay-button/guides/item-selection#multiple-item-orders)

  * [React Hooks](/payments/pay-button/guides/hooks)
</Note>

### Testing Your Integration

This demo uses the staging environment:

* Use [test credit cards](/payments/advanced/testing-tips#test-credit-card-numbers) for payments
* Get test USDC from our [faucet](/payments/advanced/testing-tips#getting-test-tokens)
* Check [price limits](/payments/advanced/testing-tips#limits-in-staging) for staging

## All Set!

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

<Frame type="simple">
  <img src="https://mintcdn.com/crossmint/QK6rWfcUCMmvIQPT/images/payments/pay-button-v3/quickstart/demo.png?fit=max&auto=format&n=QK6rWfcUCMmvIQPT&q=85&s=b65e6f7c4ad8b3ca80658296744d8bc6" width="1670" height="1624" data-path="images/payments/pay-button-v3/quickstart/demo.png" />
</Frame>

<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 launch checklist](/payments/advanced/production-launch). You will need to contact
  [Sales](https://www.crossmint.com/contact/sales) to enable the embedded checkout on production.
</Note>

## Next Steps

### Customize the UI and Behavior Further

<CardGroup cols={3}>
  <Card title="UI Customization" icon="paintbrush" iconType="duotone" href="/payments/pay-button/guides/ui-customization">
    Learn how to customize the look and feel of the checkout button
  </Card>

  <Card title="Payment Methods" icon="credit-card" iconType="duotone" href="/payments/pay-button/guides/payment-methods">
    Configure available payment options for your users
  </Card>

  <Card title="React Hooks" icon="code" iconType="duotone" href="/payments/pay-button/guides/hooks">
    Use React hooks to build custom checkout experiences
  </Card>
</CardGroup>

### Advanced Topics

<CardGroup cols={3}>
  <Card title="SDK Reference" icon="gear" iconType="duotone" color="9E9E9E" href="/payments/embedded/reference/react" />

  <Card title="Launch in Production" icon="ship" iconType="duotone" color="3AA9D8" href="/payments/advanced/production-launch" />

  <Card title="Localization" icon="globe" iconType="duotone" color="1983EF" href="/payments/pay-button/customize/localization" />

  <Card title="Multi-purchases" icon="cart-plus" iconType="duotone" color="FF7C9F" href="/payments/pay-button/guides/item-selection#multiple-item-orders" />

  <Card title="Marketplaces" icon="store" iconType="duotone" color="6366F1" href="/payments/advanced/marketplaces-and-launchpads" />

  <Card title="Testing Tips" icon="flask" iconType="duotone" color="FF6B35" href="/payments/advanced/testing-tips" />
</CardGroup>
