API Gateway vs Backend-for-Frontend
coreintermediateAn API gateway gives every client — web, mobile, third-party — the same shared entry point and the same response shape. A Backend-for-Frontend (BFF) is a separate backend layer per client type, each one shaped around what that specific client actually needs.
Think of it as
A single API gateway is one restaurant menu handed to every table, dine-in or takeout. A BFF is a menu printed differently per table type: the takeout menu drops the plating photos and adds a packaging fee line, the dine-in menu adds wine pairings — same kitchen behind both, different presentation for a different way of consuming the meal.
What we're doing: Compare how a mobile app and a web app get product-page data through a shared gateway versus through a BFF per client.
- 4
- The shared gateway sends the same rich payload to a mobile client that only renders three fields — wasted bytes on every request, worse on a mobile network.
- 9
- The mobile BFF calls the same downstream catalog-service as the web BFF, so the two are not duplicating business logic, only shaping the response differently.
Why this works: The underlying data and services are identical in both cases — the only thing that changes is whether one shared contract or several tailored ones sits in front of them, and that choice is what determines how much unused data a lean client has to receive.
Adding client-specific fields to a shared gateway response instead of introducing a BFF
Wrong
Better
What you see: The shared gateway's response-building code accumulates a growing set of per-client conditionals, a change for one client risks breaking the response shape another client depends on, and nobody can tell from the endpoint alone which fields any given client actually uses.
Why: A single shared contract branching on client type re-creates per-client shaping without the isolation a BFF would have given it — every client's special case now lives in the same file, coupled to every other client's special case.
- API Gateway
- One entry point, one response shape, for every client
- Owned by a central platform team
- Simple to run, but the contract must satisfy every client at once
- Backend-for-Frontend
- One backend per client experience (web, iOS, Android)
- Owned by the team that owns the matching client
- More services to run, but each shape fits its one client exactly
Choosing between a shared API gateway and one BFF per client
Together
Remember: An API gateway is one shared entry point and contract for every client; a BFF is one backend per client experience, shaped around what that one client actually needs. Reach for a BFF only when clients genuinely diverge — otherwise it is extra services with nothing to show for them.
See also: api gateway responsibilities · client server topology

