BFF (backend for frontend)

What is BFF

The BFF will do the following:

  • Call the relevant microservices APIs and obtain the needed data

  • Format the data based on the frontend representation

  • Send the formatted data to the frontend

BFF is similar to a proxy server between the client and other external APIs, services, etc. If the request has to go through another component, it will definitely increase latency. However, the BFF latency is negligible compared to the browser’s high resource usage if it needs to work with multiple services not optimized for the frontend.

Advantages of having a BFF

A few advantages of having a BFF are as follows:

  • Separation of concerns — Frontend requirements will be separated from the backend concerns. This is easier for maintenance.

  • Easier to maintain and modify APIs — The client application will know less about your APIs’ structure, which will make it more resilient to changes in those APIs.

  • Better error handling in the frontend — Server errors are meaningless to the frontend user most of the time. Instead of directly returning the error server sends, the BFF can map out errors that need to be shown to the user. This will improve the user experience.

  • Multiple device types can call the backend in parallel — While the browser is making a request to the browser BFF, the mobile devices can do the same. It will help obtain responses from the services faster.

  • Better security — Certain sensitive information can be hidden, and unnecessary data to the frontend can be omitted when sending back a response to the frontend. The abstraction will make it harder for attackers to target the application.

  • Shared team ownership of components — Different parts of the application can be handled by different teams very easily. Frontend teams get to enjoy ownership of both their client application and its underlying resource consumption layer; leading to high development velocities.

Last updated

Was this helpful?