Install
Import
@sigil-xyz/x402/next is a separate subpath — do not import from @sigil-xyz/x402 for Next.js usage.
Basic usage
Wrap your route handler withwithSigilAuth:
TypeScript: sigilAgent type
The wrapped handler receives aNextRequest extended with sigilAgent?: string. This is already typed inside withSigilAuth — no extra declaration needed.
Verification only
Sharing config
Define the middleware config once and reuse it across routes:Building agent headers
UsebuildSigilHeaders from @sigil-xyz/x402 in your agent code to construct the signed headers:
Error responses
On failure the middleware returns402 Payment Required: