CLI reference

x402-hosting deploy: command reference.

deploy builds the Next.js project in the current directory and publishes it to x402-hosting as a Cloudflare Worker. A first deployment costs $0.01 for the upload plus $0.20 per prepaid day; a redeployment of an existing project costs $0.01.

Next.js projectlocal OpenNext buildCloudflare Workerproduction URL
One command moves a Next.js project from a local directory to a production URL.

Synopsis

$ npx x402-hosting@latest deploy --days 30

Run it from the project root. The CLI detects the Next.js version — supported ranges are 15.5.21 up to (but not including) 16, and 16.2.11 and later — adds the OpenNext Cloudflare configuration, and builds locally. Payment only starts after the build succeeds, so a local build failure costs nothing.

What deploy does

On a first run, deploy pays $0.01 for an upload session — the payment that binds the owner wallet — uploads the artifact, and creates the project. It then pays the duration price to activate hosting. The API answers each paid step with an HTTP 402 payment challenge in USDC over the x402 protocol; that challenge is always the authoritative quote before any wallet signs. The project must activate within 30 minutes of the upload payment, or it is torn down and the $0.01 is lost. On later runs the same command publishes a new deployment at the same URL for $0.01, without changing the expiry.

Flags

  • --days <days> — hosting duration, an integer from 1 through 730; required for the first activation
  • --project-name <name> — display name, 1–80 characters; defaults to the directory name
  • --api-url <url> — API base URL; defaults to https://api.x402-hosting.com
  • --payer <mode>auto (default), env, external, or awal
  • --payer-cmd <template> — pay through any wallet CLI; mutually exclusive with --payer

Examples

$ npx x402-hosting@latest deploy --days 30 --project-name docs
$ npx x402-hosting@latest deploy --payer env

The first example creates a project named docs with thirty prepaid days. The second redeploys an existing project, paying inline from EVM_PRIVATE_KEY.

Cost

A first deployment with --days 30 costs $0.01 + 30 × $0.20 = $6.01 in total; see pricing for the full schedule. Every paid mutation must settle from the wallet that paid the first upload — a different wallet is rejected before settlement, so nothing is charged.

The project record

A successful first deployment writes x402-hosting.json to the project root with the URL, project id, owner wallet, and expiry. Commit it: every later command — status, renew, rollback, transfer, delete — finds the project through that file, and there is no way to look a project up without it.

Related guides