Skip to content

Backend for frontend (BFF)

A backend for frontend (BFF) is a small server-side service built for one kind of client: one for the web app, another for the mobile app, perhaps another for a partner portal. Each BFF calls the general-purpose backend services, then combines, filters and reshapes the results into exactly what its screens need.

The pattern was popularized by Phil Calçado and Sam Newman, based on work at SoundCloud. Its main benefit is organizational as much as technical: the team that owns a frontend also owns its BFF, so it can change both together without waiting on a shared API team.

One backend per kind of client1. The web app calls its own BFF, which holds the user's session and tokens server-side. 2. The BFF calls several core services and combines the results into one response per screen. 3. The mobile app gets a different BFF, tuned for small payloads, slower networks and app release cycles.Core services Web appbrowser Web BFFowned by web team Mobile appiOS, Android Mobile BFFowned by mobile team Ordersgeneral-purpose API Customersgeneral-purpose API Recommendationsgeneral-purpose API123
One backend per kind of client Each BFF shapes data for its own screens; the core services stay general-purpose and unaware of any particular UI.
  1. The web app calls its own BFF, which holds the user's session and tokens server-side.
  2. The BFF calls several core services and combines the results into one response per screen.
  3. The mobile app gets a different BFF, tuned for small payloads, slower networks and app release cycles.
  • One BFF per client experience, not per screen and not one for all clients. “Web” and “mobile” is the usual split, because their needs and release cycles differ.
  • Aggregation and shaping. One screen often needs data from several services. The BFF calls them, in parallel where possible, and returns one tailored response, reducing round trips from the device.
  • Owned by the frontend team. The BFF changes in step with the UI, in the language the team prefers (often TypeScript on Node.js).
  • Security: the token-handler pattern. For browser apps, a BFF can perform the OAuth flow server-side and keep access tokens out of JavaScript entirely, using a secure, HTTP-only session cookie with the browser. Current IETF guidance for browser-based apps describes this approach.
  • Keep business logic out. A BFF translates and composes. Rules like pricing or eligibility belong in the core services, or they’ll be duplicated in every BFF.
  • GraphQL is an alternative, or a BFF implementation: one schema that each client queries for exactly the fields it needs.
  • Faster frontend delivery: teams don’t wait on a shared API to add a field.
  • Better performance on devices: fewer, smaller responses.
  • Better security for browser apps: tokens stay on the server.
  • More services to build, deploy and operate.
  • Duplication between BFFs if they aren’t kept thin.
  • Another network hop, which adds a little latency if the BFF does nothing useful.
  • Several client types (web, mobile, partners, devices) with clearly different needs.
  • Screens that need data from many services at once.
  • Browser apps that should keep OAuth tokens out of the browser.

With one client and a backend that already fits it, a BFF is an extra hop for no gain. An API gateway may already handle routing, authentication and rate limiting for you.

  • One “BFF” shared by every client, which turns into the general-purpose API you were trying to avoid.
  • Business rules in the BFF, duplicated and drifting between web and mobile.
  • Sequential calls to downstream services instead of parallel ones.
  • No ownership: a BFF built by a separate backend team loses most of its benefit.

Glossary: API gateway

Written and edited by Abhinav Taduka, enterprise software architect.