SERVER COMPONENTS │ NO API ROUTE │ NO LOADING STATE

Components that pay.

Every x402 guide shows you how to charge. This one shows you how to spend. Weft takes the place of the backend call, so the purchase happens while the page renders and the component arrives with its data already in it.

New to the protocol? Start with what x402 is.

One file finds it, pays for it, and draws it.

Write the card by hand or generate it from the response — hover a line to see what it drew, click either side to keep it.

RENDERED ON THE SERVER
app/domain/[name]/page.tsx
// app/domain/[name]/page.tsx — one Server Component, no API routeimport { WeftClient } from "@weft-labs/sdk"; const weft = new WeftClient({ apiKey: process.env.WEFT_API_KEY! }); export default async function DomainCard({ params }) {  // ask for a capability, not a vendor — then take the cheapest  const hit = (await weft.search({ query: "domain registration data" }))    .results.flatMap((x) => x.endpoints)    .sort((a, b) => +a.price.indexedUsd - +b.price.indexedUsd)[0];   const d = JSON.parse(atob(r.bodyBase64));   return (    <Card>      <Row>      </Row>    </Card>  );}
<DomainCard />FIRST PAINT
openai.com
MarkMonitor Inc.
6 locks
REGISTERED
19 Jan 2007
AGE
7,160 days
EXPIRES
19 Jan 2029
2007today2029
NAMESERVERS
ns1-02.azure-dns.comns2-02.azure-dns.netns3-02.azure-dns.orgns4-02.azure-dns.info
RDAP · x402 on Basepaid $0.005 · 0x94dd71…

□ PURCHASED FROM X402 ATLAS FOR $0.005.

Two lines change, a different feature ships.

The page does not know what it is buying. Same key, same wallet, same ceiling flag, same ledger — and again the card renders full.

THE DIFF
- weft.search({ query: "domain registration data" })
+ weft.search({ query: "geocode a street address" })

- url: `${hit.url}?domain=${params.name}`,
+ url: `${hit.url}?address=${params.q}`,
<PlaceCard />FIRST PAINT
Bahnhofstrasse 1
Lindenhof, Altstadt · 8001 Zürich, Schweiz
LATITUDE
47.3672965
LONGITUDE
8.5398712
commercialOpenStreetMap
Strale · x402 on Basepaid $0.0216 · 0xbd2773…

What the second feature costs.

WITHOUT WEFT

  1. 01open an account with the provider, add a card
  2. 02mint an API key, then find somewhere safe to keep it
  3. 03write the API route that holds it, and the client fetch that calls it
  4. 04add a loading state, because the data arrives after the paint
  5. 05repeat, per provider, per feature

WITH WEFT

  1. 01one await, in the component that needs the data
  2. 02maxCostUsd on the call — the ceiling is the rate limiter
  3. 03swap the query to change provider; nothing else moves

A second feature costs a second query.

Add it to your app.

One key, one ceiling, every provider in the index.

pnpm add @weft-labs/sdk

Prefer a shell? Find, pay and pipe an x402 endpoint from your terminal.