-
Book Overview & Buying
-
Table Of Contents
React Application Architecture for Production - Second Edition
By :
REST APIs work well for most applications, but as applications grow, two challenges tend to emerge. First, the frontend needs more data than any single REST endpoint provides, leading to multiple round-trip requests (under-fetching) or bloated endpoints that return everything just in case (over-fetching). Second, different clients (web, mobile, third-party) need the same data shaped differently.
The Backend for Frontend (BFF) pattern addresses both problems by adding a thin API layer that sits in front of our backend and is tailored to a specific client's needs.
Instead of a generic API that all clients share, each client gets its own BFF. The web BFF knows exactly what data the web app needs and aggregates it in one request. If the underlying data comes from three different services, the BFF handles the fan-out and returns a single, composed response. The following diagram shows how this sits between the clients and the backend:

Figure 13.2...