Agents

One command deploy as an agent primitive.

Publishing a Next.js app on x402-hosting is one command run from the project root, and for an agent that is the point. A task like "publish this app" becomes a single deterministic step that can be planned with a known cost, executed without interaction, and verified with a free read. There is no setup phase around it.

$ npx x402-hosting@latest deploy --days 30
Next.js projectlocal OpenNext buildCloudflare Workerproduction URL
One command moves a Next.js project from a local directory to a production URL.

One atomic step in a plan

Agent plans fail at the seams: the half-configured account, the form that changed, the dialog that needs a human. A single command has no seams. The CLI detects the Next.js version, configures an OpenNext build, builds the artifact locally, pays the HTTP 402 challenge in USDC, and publishes the project as a Cloudflare Worker. Either the command succeeds and the URL exists, or it fails before payment and nothing was spent.

Nothing to install

The command runs through npx, so there is no global package to install, no daemon to keep alive, and no credentials file to prepare. An agent with a shell and a funded wallet already has everything the deploy needs. On the first deployment the CLI adds its build configuration to the project itself — the OpenNext Cloudflare dependencies, an x402:build script, open-next.config.ts, and wrangler.jsonc — so the setup becomes part of the repository rather than part of a machine.

The outcome is recorded

A successful first deployment writes x402-hosting.json to the project root with the URL, project id, owner wallet, and expiry. The file contains no secret and belongs in the repository. For an agent it is the durable artifact of the step: later runs read it to redeploy, renew, or roll back without rediscovering anything.

Verification is a separate free step

Because status reads cost nothing, an agent can close the loop after the deploy instead of trusting the exit code alone. Run npx x402-hosting@latest status --json and confirm the project is active at the recorded URL. Plan, execute, verify — each part is explicit.

What the step assumes

The primitive stays simple because its contract is narrow. Supported Next.js versions are 15.5.21 up to (but not including) 16, and 16.2.11 and later. A first deployment must activate within thirty minutes of the upload payment, which for a normal run is immediate. An active project includes its static assets, 100,000 dynamic requests, and 15 million CPU milliseconds. Those bounds are fixed, so the agent can check eligibility before running the command rather than discovering a limit after it.

The cost side is equally plain: $0.20 per project-day plus a one-time $0.01 upload payment on the first deploy, prepaid in USDC. Thirty days is $6.01, quoted by the payment challenge before any wallet signs.

Why this works as a primitive

  • One command covers build, payment, and publish
  • Cost is fixed and quoted before any wallet signs
  • x402-hosting.json records the outcome next to the code
  • Free status reads confirm the result
  • A local build failure never reaches payment

Related guides