Rebilder Docs
Install the gateway in under 30 minutes.
One package, zero external dependencies, four adapters. Agents get clean markdown from your source of truth; humans and crawlers never notice a thing.
What the gateway is
@rebilder/gateway is the front door of the Rebilder compiler: content-negotiation middleware you drop in front of your existing stack. It classifies every request — AI agent, human, search crawler, or protocol client — and serves agents a clean markdown transformation of the canonical page, rendered from your source of truth. Humans and crawlers pass through untouched, as if the gateway weren’t there.
- Markdown path — an agent asking with
Accept: text/markdown(or an identified agent platform) gets atext/markdownresponse rendered from your product, policy, and catalog data. Front-loaded buying facts, under 5KB by default. - Pass-through — humans and search crawlers get
nullfrom the gateway, so your HTML pipeline runs unchanged. Googlebot always receives canonical HTML. - Events — every handled request, including pass-throughs, emits one
RebilderEventV0to youronEventhook: who asked, what they got, how long it took. That feed powers the Console.
The difference is not subtle. In the captured demo, the same product request dropped from 91,226 bytes of PDP HTML to 1,315 bytes of markdown — a 98.6% reduction, with the price moving from character offset 23,185 to line 4. The numbers on the homepage are drift-tested against that capture.
The 30-minute quickstart
These docs are built so a stranger can install the gateway in under 30 minutes without talking to us. The whole integration is one install, two small files, and two curl commands to prove it works:
- Install
@rebilder/gateway— zero external runtime dependencies, by policy. - Wire your source of truth: three optional resolver functions (
product,policies,catalog) from URL to your catalog data. - Mount the adapter for your stack — Next.js middleware, Shopify app proxy, Express/Fastify, or a Cloudflare Worker.
- Verify with curl: same URL, markdown for agents, unchanged HTML for everyone else.
Start here: Quickstart — Next.js end to end. On another stack? Jump straight to the Shopify, Node, or Cloudflare adapter pages — the config object is identical everywhere.
Built for production stacks
- Zero external runtime dependencies. The gateway’s only runtime deps are internal workspace packages, and it re-exports their public types — you install one package. No framework imports anywhere: the core is written against web-standard
Request/Response. - Edge latency budget: p95 < 50ms compute, no network calls on the hot path. Classification is a handful of header string scans (well under 1ms); rendering is pure string assembly. Your source resolvers are the only variable — back them with in-memory data or a fast cache.
- Failure containment. A source that throws is treated as "no match"; a render failure passes through to HTML; a broken event sink is swallowed. The gateway never breaks your site — that is the contract, and every rule is a test.
Guarantees
Everything in these docs
| Page | What it covers |
|---|---|
| Quickstart | Next.js end to end: install, wiring, a complete catalog example, curl verification. |
| Next.js adapter | proxy.ts / middleware.ts integration, the dedicated markdown route, matcher scope. |
| Shopify adapter | App-proxy setup in Partners, the HMAC security model, response semantics. |
| Node adapter | Express middleware, Fastify via @fastify/middie or an onRequest hook, structural types. |
| Cloudflare & edge | The worker fetch handler, origin pass-through, Vercel Edge and other WinterCG runtimes. |
| Sources | The GatewaySources contract: field-by-field types, resolution order, error containment. |
| Classification | How requests are detected: the five checks, the crawler guardrail, confidence semantics. |
| Events | RebilderEventV0 field reference, the wire protocol, the HTTP and console sinks. |
| llms.txt | Deterministic llms.txt generation — and an honest note on its effectiveness. |
| Troubleshooting | Real failure modes with fixes. |
| API reference | Every public export of @rebilder/gateway and @rebilder/events, with signatures. |
Further reading: for the non-API side of all this — what agentic commerce is, how shopping agents read stores, and how the ACP/UCP/MCP protocols fit together — see the Learn hub.
