React
The React hooks are the most ergonomic path when you want a payment-aware UI instead of manually orchestrating status, balances, and retry state yourself.
useX402Payment
The main React entrypoint is useX402Payment.
Sponsored Recommendations
When a payment settles and the facilitator returns sponsored recommendations, the hook automatically:
- Populates
sponsoredRecommendationswith typedSponsoredRecommendation[] - Fires the impression beacon to confirm delivery to the ad network
The sponsoredRecommendations value is null until a payment completes with recommendations. It resets to null when you call reset().
See Sponsored Access for the full system.
Why This Is Better Than Wiring It Yourself
The hook consolidates:
- payment state (
status: idle, pending, success, error) - request lifecycle (402 detection, signing, settlement)
- balances across all connected chains
- transaction links (auto-generated explorer URLs)
- error handling with typed
X402Errorcodes - sponsored recommendation delivery and impression tracking
That is especially useful in applications where the same user may pay across more than one screen.
Recommended UI Pattern
A practical pattern is:
- show whether the wallet is connected
- show known balance state
- keep the payment action explicit
- surface the transaction URL after settlement
- display sponsored recommendations if present
When To Reach For useAccessPass
If your product has repeated reads against the same protected surface, useAccessPass usually creates a better UX than signing every request individually.
Read next: