create-typescript-x402-nextjs

Create Next.js applications with x402 payment-gated API routes using Algorand payments.

Updated Apr 6, 2026
One-click install
npx skills add https://github.com/Rudhrakoushik10/RootNode --skill create-typescript-x402-nextjs-rudhrakoushik10
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: create-typescript-x402-nextjs
Source: https://github.com/Rudhrakoushik10/RootNode/tree/main/projects/.opencode/skill/create-typescript-x402-nextjs
Command: npx skills add https://github.com/Rudhrakoushik10/RootNode --skill create-typescript-x402-nextjs-rudhrakoushik10

SYSTEM DOCUMENTATION & REQUIREMENTS

💡 This Skill requires @x402-avm/next, @x402-avm/avm, @x402-avm/core, @x402-avm/paywall, and includes references (resource) components.

What problem does it solve? Monetizing Next.js API routes and pages requires integrating payment verification, settlement, and HTTP 402 responses, which is complex to implement correctly from scratch. This Skill provides two ready-made integration patterns for adding Algorand-based payment protection to Next.js App Router projects. ## Core Features & Use Cases - Proxy Pattern via middleware.ts: Centrally protect multiple API routes with paymentProxy or paymentProxyFromConfig, including wildcard route patterns and paywall UI for browser requests. - Route Handler Wrapper via withX402: Protect individual endpoints with per-route pricing, where payment settles only when the handler returns a status below 400. - Multi-network and token support: Accept payments on Algorand testnet and mainnet, in ALGO or USDC, and even cross-chain with EVM networks. - Use Case: Build an API that charges $0.01 per weather query and $1.00 per AI generation request, with a free health-check endpoint, all configured in a single middleware.ts file. ## Quick Start Ask the AI to create a Next.js app with x402 payment protection on the /api/weather route charging $0.01 in ALGO on Algorand testnet.

Frequently Asked Questions about create-typescript-x402-nextjs

High-intent search queries and answers about installing and using this skill.

FAQPage Schema
How do I add payment protection to Next.js API routes?

Use the proxy pattern by creating a middleware.ts file at the project root with paymentProxyFromConfig, defining route patterns with prices and your Algorand payTo address. Alternatively, wrap individual route handlers with the withX402 function for per-endpoint control.

What is the difference between paymentProxy and withX402 in x402 Next.js?

paymentProxy centralizes route protection in middleware.ts and settles payment when forwarding the request. withX402 wraps individual route handlers and only settles payment when the handler returns a status below 400, protecting users from paying for failed requests.

Can I accept USDC payments on Algorand with x402?

Yes, specify the USDC ASA ID in the route config's extra.asset field, such as USDC_TESTNET_ASA_ID (10458941) for testnet or USDC_MAINNET_ASA_ID (31566704) for mainnet. The price field still uses dollar notation like "$5.00".

Why is my Next.js x402 middleware not running?

The middleware.ts file must be located at the project root next to the app directory, otherwise Next.js will not load it. Also verify the matcher config targets your API routes, such as "/api/:path*", and that PAY_TO is set in .env.local.

Does x402 Next.js support both Algorand testnet and mainnet?

Yes, provide an array of accepts entries in the route config, one with ALGORAND_TESTNET_CAIP2 and one with ALGORAND_MAINNET_CAIP2, each with its own payTo address. Clients can then pay on either network.

How do I keep some Next.js routes free while others require payment?

With the proxy pattern, exclude free routes from the middleware matcher or omit them from the routes config. With withX402, simply do not wrap the handlers of routes that should remain free.