One-click deploy with the Vercel template
One-click deploy with the Vercel template
The Vercel template is a standalone Next.js app that clones into your GitHub and deploys a working pay-per-call API. The demo is a fortune teller that exercises every pricing mode.To make it your own, replace the routes in
2
Set three environment variables
The deploy flow prompts for them inline:
EVM_PAYEE_ADDRESS: the0x…wallet that receives payments.CDP_API_KEY_IDandCDP_API_KEY_SECRET: Coinbase Developer Platform credentials for the default x402 facilitator. The CDP free tier is enough.
BASE_URL is auto-derived from Vercel’s system env vars, so there is no manual step.3
Call it
The landing page at your deployment’s root lists every endpoint with a copy-pasteable command:
app/api/fortune/* with your endpoints, add each new route file to lib/routes.ts, and update the title and guidance in lib/router.ts. Push to GitHub and Vercel redeploys.Minimal server from scratch
The router runs on any fetch runtime, including Next.js, Hono, Bun, and Node. Below is a complete server in one file, using Hono on Node:1
Create the project
2
Write the server
server.ts
3
Set the environment and run
/api/*, and discovery (/openapi.json, /llms.txt) works immediately.4
Deploy anywhere
The server is a plain Node process: deploy it to Fly, Railway, a VPS, or any container host. Set
BASE_URL to your public origin (it’s the 402 realm and OpenAPI server URL, so it must match the domain agents call), and add an Upstash KV for production. See Configuration.examples/hono. Bun, Deno, and Cloudflare Workers work the same way via router.fetch. See Hosting.
Add to an existing app (Next.js)
1
Install
zod (v4) is a peer dependency.2
Create the router
createRouterFromEnv reads config from process.env and validates every value up front. Set EVM_PAYEE_ADDRESS, CDP_API_KEY_ID, and CDP_API_KEY_SECRET (plus BASE_URL outside Vercel).lib/router.ts
3
Register routes
One side-effect module registers every route:
lib/routes.ts
4
Serve it
Test the 402 flow
An unpaid request gets a402 whose challenge lives in headers: