Documentation Index
Fetch the complete documentation index at: https://docs.faremeter.xyz/llms.txt
Use this file to discover all available pages before exploring further.
The Hono middleware works the same way as Express but uses Hono’s middleware API.
pnpm add @faremeter/middleware @faremeter/info hono
Basic setup
import { Hono } from "hono"
import { createMiddleware } from "@faremeter/middleware/hono"
import { x402Exact } from "@faremeter/info/solana"
const app = new Hono()
const paymentWall = await createMiddleware({
facilitatorURL: "https://facilitator.corbits.dev",
accepts: [
...x402Exact({
network: "devnet",
payTo: "7xKXwxRPMo2sUAT5...",
asset: "USDC",
amount: "10000",
}),
],
})
app.get("/protected", paymentWall, (c) => {
return c.json({ data: "paid content" })
})
app.get("/free", (c) => {
return c.json({ data: "free content" })
})
export { app }
App-level middleware
app.use("/*", paymentWall)
Multiple payment methods
Same configuration as Express — pass multiple requirements to the accepts array:
import { x402Exact as solanaX402Exact } from "@faremeter/info/solana"
import { x402Exact } from "@faremeter/info/evm"
const paymentWall = await createMiddleware({
facilitatorURL: "https://facilitator.corbits.dev",
accepts: [
...solanaX402Exact({ network: "devnet", payTo: "7xKX...", asset: "USDC", amount: "10000" }),
x402Exact({ network: "base-sepolia", payTo: "0x1234...", asset: "USDC", amount: "10000" }),
],
})
Differences from Express
The core logic is identical. The only difference is the middleware signature:
- Express:
(req, res, next) => void
- Hono:
(c, next) => Promise<void>
The createMiddleware function from @faremeter/middleware/hono returns a Hono-compatible middleware. Configuration, payment requirements, and facilitator interaction are the same.
Further reading