The Case for a BFF

2 min read Original article ↗

BFF is a type of smart API gateway that has its unique place in modern web services. This article presents several valid arguments in favor of integrating a Backend for Frontend (BFF) into your system.

  • A BFF API has the capability to consolidate multiple API requests to downstream backend services, thereby reducing the number of round trips needed.

  • Reduce the response payload size from downstream services.

  • Redact or remove sensitive payload from downstream services.

  • BFF is potentially the best place to implement server push or notifications (such as WebSockets).

  • BFF is the service to store frontend states, which do not make sense for downstream services, for instances:

    • Which page the user is currently working on.

    • Partially filled form data.

  • BFF can host client specific logic that doesn’t make sense in downstream resource oriented services.

  • BFF can host additional assistance frontend focused features, such as

    • Autocomplete

    • Search

  • Reusability: Centralizing frontend business logics.

    • Devs don’t need to rewrite the same logic for iOS, Android and Web.

    • Consistency in business logic across platforms improves user experience.

    • Even if platforms have to use distinct logics, BFF helps document them as code in the same service.

  • Backend-driven rendering. Enables faster experimentation and bypasses slow iOS/Android release cycles.

  • Faster iteration and autonomy for the frontend team.

References:

  • https://samnewman.io/patterns/architectural/bff/, very good article that shares concerns on further implementation tradeoffs.

  • https://learn.microsoft.com/en-us/azure/architecture/patterns/backends-for-frontends

Discussion about this post

Ready for more?