Documentation menu

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.

Request flow: every request is classified; agent traffic is served markdown rendered from sources, humans and crawlers pass through to canonical HTML, protocol routes pass through until Phase 3, and every path emits one event.Requestany URLclassifyRequestpure compute, <1msmarkdown — render from sourcestext/markdown · Vary: Accept · <5KBagenthtml — pass through untouchedhumans AND crawlers (Googlebot: always)human · crawlerprotocol — pass throughendpoints land Phase 3; demand recorded now/mcp · /.well-knownRebilderEventV0via onEvent — every path
  • Markdown path — an agent asking with Accept: text/markdown (or an identified agent platform) gets a text/markdown response rendered from your product, policy, and catalog data. Front-loaded buying facts, under 5KB by default.
  • Pass-through — humans and search crawlers get null from the gateway, so your HTML pipeline runs unchanged. Googlebot always receives canonical HTML.
  • Events — every handled request, including pass-throughs, emits one RebilderEventV0 to your onEvent hook: 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:

  1. Install @rebilder/gateway — zero external runtime dependencies, by policy.
  2. Wire your source of truth: three optional resolver functions (product, policies, catalog) from URL to your catalog data.
  3. Mount the adapter for your stack — Next.js middleware, Shopify app proxy, Express/Fastify, or a Cloudflare Worker.
  4. 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

PageWhat it covers
QuickstartNext.js end to end: install, wiring, a complete catalog example, curl verification.
Next.js adapterproxy.ts / middleware.ts integration, the dedicated markdown route, matcher scope.
Shopify adapterApp-proxy setup in Partners, the HMAC security model, response semantics.
Node adapterExpress middleware, Fastify via @fastify/middie or an onRequest hook, structural types.
Cloudflare & edgeThe worker fetch handler, origin pass-through, Vercel Edge and other WinterCG runtimes.
SourcesThe GatewaySources contract: field-by-field types, resolution order, error containment.
ClassificationHow requests are detected: the five checks, the crawler guardrail, confidence semantics.
EventsRebilderEventV0 field reference, the wire protocol, the HTTP and console sinks.
llms.txtDeterministic llms.txt generation — and an honest note on its effectiveness.
TroubleshootingReal failure modes with fixes.
API referenceEvery 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.