Next.js Integration
Installation
pnpm add @shade402/nextjs @shade402/coreSetup
Initialize Configuration
// lib/x402-config.ts
import { initX402 } from '@shade402/nextjs';
export function configureX402() {
if (typeof window === 'undefined') {
// Server-side only
initX402({
paymentAddress: process.env.PAYMENT_WALLET_ADDRESS!,
tokenMint: process.env.TOKEN_MINT!,
network: process.env.SOLANA_NETWORK || 'solana-devnet',
rpcUrl: process.env.SOLANA_RPC_URL,
autoVerify: true,
defaultAmount: '0.01',
paymentTimeout: 300,
});
}
}API Routes
Pages Router
Configuration Options
Accessing Payment Information
Error Handling
Multiple Payment Tiers
Environment Variables
Complete Example
Client-side Integration
Best Practices
Next Steps
Last updated
