Last Updated: January 8, 2026
In the previous chapter, we explored the API Gateway pattern, which provides a single entry point for all clients.
But consider the diverse needs of different client types. A mobile app running on a slow network needs compact responses with minimal data. A web application on a desktop can handle richer payloads and multiple parallel requests. A third-party integration might need entirely different data formats and authentication schemes.
Forcing all clients through a single gateway creates a tension.
The Backend for Frontend (BFF) pattern solves this by creating separate gateway layers for each client type. Each BFF is tailored to the specific needs of its client, providing optimized APIs that make sense for that platform.
In this chapter, you will learn:
The BFF pattern is particularly relevant for organizations with multiple client applications serving different user experiences.
Consider an e-commerce platform with three client types: a web application, a mobile app, and a partner API.
Each client needs different data for the same conceptual screen:
When all clients share one gateway, changes must accommodate the slowest-moving client. A web team wanting to add a field must wait until mobile apps can handle it.
The gateway accumulates client-specific logic, becoming harder to maintain. Changes for one client risk breaking others.
The BFF pattern creates a separate backend for each type of frontend. Each BFF is tailored to its client's specific requirements.
Each BFF:
The mobile BFF provides a compact endpoint optimized for mobile clients:
The web BFF provides a richer endpoint for the web application:
The BFF:
The frontend team owns their BFF. They control the API contract and release schedule.
A platform team owns all BFFs, providing APIs to frontend teams.
The right model depends on team structure and organization culture. Many organizations start with platform ownership and gradually shift to team ownership as capabilities mature.
The BFF pattern and API Gateway pattern solve related but different problems.
| Aspect | API Gateway | BFF |
|---|---|---|
| Purpose | Single entry point, cross-cutting concerns | Client-specific API optimization |
| Number | One (or few for regions) | One per client type |
| Ownership | Platform/infrastructure team | Frontend team or platform team |
| Logic | Routing, auth, rate limiting | Data aggregation, transformation |
| Coupling | Loose coupling to clients | Tight coupling to specific client |
They are often used together:
Extract common code into libraries shared across BFFs.
Share:
Do not share:
Use GraphQL to let clients request exactly what they need.
Multiple BFFs compose into a unified API.
This works when domain teams own their BFF slices and a thin orchestration layer composes them.
| Scenario | Why BFF Helps |
|---|---|
| Multiple distinct client types | Each BFF optimized for its client |
| Different release cadences | BFFs can evolve independently |
| Significant data transformation | Client-specific formatting |
| Different interaction patterns | Mobile vs web vs IoT |
| Separate frontend teams | Teams own their BFFs |
| Scenario | Alternative |
|---|---|
| Single client type | General API Gateway |
| Identical needs across clients | Shared API Gateway |
| Simple CRUD operations | Direct service access |
| Limited development resources | Single gateway simpler to maintain |
BFFs should aggregate and transform, not implement business logic.
Document the API contract for each BFF using OpenAPI or similar.
Track metrics separately for each BFF to understand client-specific issues.
BFFs should provide degraded responses when backend services fail.
If the Review service is down, return product data without reviews rather than failing entirely.
BFFs can share:
BFFs should not share:
The BFF accumulates more and more logic until it becomes a new monolith.
Prevention: Regularly review what belongs in the BFF vs. backend services. Refactor business logic to appropriate services.
Similar logic implemented differently in each BFF.
Prevention: Extract shared functionality into libraries. Use code generation for service clients. Establish patterns that all BFFs follow.
Creating a BFF for every slight variation in client needs.
Prevention: Group by meaningful differences. iOS and Android apps with similar needs can share a Mobile BFF. Only create separate BFFs when requirements genuinely diverge.
BFF APIs need versioning just like any API.
Prevention: Version BFF endpoints from the start. Plan deprecation cycles. Communicate changes to client teams.
The Backend for Frontend pattern addresses the limitations of a single API Gateway when serving diverse client types: