@ftptech/x402-canton-next
v0.2.2
Published
Next.js App Router wrapper to gate Route Handlers behind Canton x402 payment via a facilitator.
Maintainers
Readme
@ftptech/x402-canton-next
Next.js App Router wrapper that gates a Route Handler behind Canton x402 payment via a facilitator.
Install
npm i @ftptech/x402-canton-core @ftptech/x402-canton-nextNote: the
@ftpnpm scope is not final and may change before the first public release (seedocs/PUBLISHING.md). Pin the version you install and check the README for the current package name.
Quick example
// app/api/data/route.ts
import { withCantonPayment } from "@ftptech/x402-canton-next";
export const GET = withCantonPayment(
async () => Response.json({ data: "premium" }),
{
accepts: [paymentRequirements],
facilitatorUrl: process.env.FACILITATOR_URL!,
description: "Premium data feed",
mimeType: "application/json",
}
);Per-request flow matches @ftptech/x402-canton-express: facilitator
/verify → pre-handler /settle → handler → response with
PAYMENT-RESPONSE header attached.
No next dependency
This package uses plain Web Fetch Request/Response/Headers.
Next.js's NextRequest extends Request, so the wrapper composes
without pinning a next version.
