Backend for Frontend (BFF) Pattern
The Backend for Frontend (BFF) pattern creates a separate backend service tailored to the specific needs of each frontend client (web, mobile, TV, partner API), rather than forcing all clients to share a single general-purpose API.
What It Really Means
Different clients have fundamentally different needs. A mobile app on a cellular network needs compact responses, minimal round trips, and offline-friendly data structures. A desktop web dashboard needs rich, detailed payloads with real-time updates. A smart TV app needs a completely different data shape optimized for large screens and remote control navigation. A partner API needs stable, versioned endpoints with comprehensive documentation.
When you force all these clients through a single API gateway, one of two things happens: the API becomes a lowest-common-denominator that serves no client well, or it becomes an over-featured monster with client-specific query parameters, conditional fields, and response transformations that are impossible to maintain.
The BFF pattern solves this by giving each client type its own dedicated backend. The mobile BFF aggregates data from downstream services into compact responses. The web BFF returns richer payloads with different field sets. Each BFF is owned by the frontend team that consumes it, so they can evolve the API at the pace their client needs without coordinating with other teams.
Sam Newman popularized the pattern in his work on microservices. The key insight is that the BFF is not a general-purpose service — it is an extension of the frontend, living at the boundary between the client and the core domain services.
How It Works in Practice
Architecture Overview
Real-World Example: SoundCloud
SoundCloud adopted the BFF pattern to serve their web player, mobile apps, and third-party developer API. Each had different requirements:
- Web BFF: Returns full track metadata, waveform data, social interactions, and real-time comment streams. Optimized for the rich web player experience.
- Mobile BFF: Returns compact track data, pre-computed playlist sequences for offline mode, and image URLs at device-appropriate resolutions. Minimizes payload size and round trips.
- Public API BFF: Returns stable, versioned responses following the public API contract. Changes go through a deprecation process.
When the mobile team needed to add offline playlist syncing, they modified the Mobile BFF to return pre-computed sync deltas. No coordination with the web team or the core services team was needed.
What a BFF Does
Response aggregation: The mobile BFF calls the User Service, Order Service, and Recommendation Service, then merges the results into a single response optimized for the home screen.
Response shaping: The web BFF returns {user: {name, avatar, bio, stats, recentActivity}}. The mobile BFF returns {user: {name, avatarSmall}}. Same downstream data, different shapes.
Protocol translation: Core services use gRPC internally. The web BFF exposes REST endpoints. The mobile BFF might expose GraphQL for flexible querying.
Client-specific logic: The TV BFF applies different pagination (larger page sizes for TV grids), different image sizes, and different sorting optimized for TV UX.