x402-hono
Hono middleware integration for the x402 Payment Protocol. This package allows you to easily add paywall functionality to your Hono applications using the x402 protocol.Installation
Quick Start
Configuration
ThepaymentMiddleware
function accepts three parameters:
payTo
: Your receiving address (0x${string}
)routes
: Route configurations for protected endpointsfacilitator
: (Optional) Configuration for the x402 facilitator servicepaywall
: (Optional) Configuration for the built-in paywall
Middleware Options
The middleware supports the same configuration options as the Express middleware:Route Configuration
Payment Configuration
Example with Cloudflare Workers
Edge Runtime Support
Hono’s lightweight design makes it perfect for edge computing environments. The x402-hono middleware works seamlessly with:- Cloudflare Workers
- Vercel Edge Functions
- Deno Deploy
- Bun runtime
Performance Benefits
- Minimal overhead: Hono’s fast routing combined with x402’s efficient payment protocol
- Edge-optimized: Perfect for serverless and edge computing environments
- TypeScript-first: Full type safety for payment configurations and responses