x402-nuxt Playground

Connect MetaMask (top right), then try each pricing mode. Payments use test USDC on Base Sepolia.

1. Fixed price paywall

One price for everyone, set in nuxt.config. Access is kept in a signed cookie for 24 hours.

'GET /api/premium': { price: '$0.001' }

2. Donation (payer-chosen amount)

The amount comes from an input field. The server only accepts it within the min/max set in nuxt.config.

'POST /api/donate': { price: { min: '$0.001', max: '$10' } }

3. Price per item

Each article has its own price, looked up on the server. Paying for one article unlocks only that article.

defineX402Handler({ price: event => ({ amount, key: 'article:slug' }) }, handler)

4. Shop checkout

The browser only says which order to pay. The server reads the order total, so the amount cannot be changed on the client. Each order is paid once.

defineX402Handler({ price: event => ({ amount: order.total, key: 'order:id' }) }, handler)

The /api/hello endpoint is not protected and returns data freely.