Using x402 payments with Privy
Enable users to pay for APIs and content using x402, the new HTTP payment protocol. Privy’s x402 integration helps integrate x402 payment authorizations from embedded wallets in both client-side React apps and server-side Node.js applications. Payment settlement is handled by the selected facilitator.What is x402?
x402 is an open payment protocol that enables instant, automatic payments for APIs and digital content over HTTP. When a resource requires payment, the server responds with402 Payment Required. The client constructs an X-PAYMENT header with a signed payment authorization and retries the request.
Installation
- React
- Node.js
useX402Fetch hook is built into @privy-io/react-auth (v3.7.0+).Usage
Basic example
- React
- Node.js
Using default connected wallet
- React
With maximum payment protection
- React
Key details
Requirements:- Users need USDC in their Privy embedded wallet on the correct network (e.g. Base, Base Sepolia, or Solana)
- The facilitator pays gas fees (users only need USDC, not ETH or SOL)
- For testnet: Get free USDC from Circle’s faucet
x402 facilitators
Facilitators are services that verify payment authorizations and submit transactions onchain on behalf of users. They handle gas fees and transaction settlement, allowing users to pay only with USDC without needing native tokens like ETH or SOL. Several x402 facilitators are available, including:- Pay AI: facilitator, docs
- Corbits: facilitator, docs
- Coinbase: facilitator, docs

