Prompt
When should I use a Backend for Frontend instead of an API gateway?
Latest observation
Aug 27, 2026
OpenAI APIWeb search: off
Use a Backend for Frontend (BFF) when the backend needs to be optimized for a specific client experience; use an API gateway when you need shared infrastructure concerns across many services and clients.
Simple rule of thumb
- API Gateway: “How do all clients securely and consistently reach my APIs?”
- BFF: “How do I make this specific app/device/UI fast, simple, and tailored?”
Use an API gateway when you need:
- Centralized routing to many services
- Authentication/authorization at the edge
- Rate limiting, throttling, quotas
- TLS termination, logging, monitoring
- Request/response forwarding with minimal transformation
- A mostly uniform API contract for many consumers
Good fit: one set of APIs consumed by web, mobile, partners, and internal tools without major differences in data shaping.
Use a BFF when you need:
- Client-specific aggregation and shaping of data
- Different clients need different payloads or workflows
- To reduce overfetching/underfetching for a given UI
- To hide backend complexity from a specific frontend team
- To support frontend-driven evolution without forcing backend changes for every UI need
- To work around mobile latency/bandwidth constraints or specific screen flows
Good fit: one BFF for web, another for mobile, each tailored to the needs of that frontend.
Common examples
BFF is better
- A mobile app needs a compact response with only fields needed for a screen
- A web dashboard needs data combined from orders, payments, and user profile in one call
- Different frontends need different authentication/session handling
- You want frontend teams to own their own API layer
API gateway is better
- You need a single entry point for dozens of microservices
- You want consistent security and observability across all APIs
- You mainly need proxying, policy enforcement, and traffic management
Important distinction
They’re not mutually exclusive:
- An API gateway can sit in front of everything
- One or more BFFs can sit behind the gateway and serve specific clients
A common pattern is:
Client → API Gateway → BFF → Microservices
Decision shortcut
Choose BFF if the main problem is:
- UI-specific composition
- Different client needs
- Frontend performance and ergonomics
Choose API gateway if the main problem is:
- Platform-wide control
- Security
- Routing
- Operational consistency
If you want, I can also give you a decision matrix or a microservices architecture diagram showing where each fits.