# BFF (Backend For Frontend)
# What I know:
- When frontend requires to reformat some data in order for UI to display
- After BFF built, which allows developer to make batch calls instead of making multiple API requests, which is better performance considerations [Aggregate API calls]
- We are able to have multiple BFFs, such as browser BFF, mobile BFF and etc
- BFF is like a bridge, which calls backend APIs and format the data like frontend required and send those format data to frontend to use [data abstraction]
# Why we need BFF?
- Easier to maintain and modify APIs
- Easier to separate the ownership of services (less conflicts/overlaps)
- Better error handling for frontend, more user friendly
- Better Security, like token can be hidden (not exposed to browser), also some sensitive data would be able to be omitted if not needed
# When to use BFF?
When backend is using micro-services architecture. BFF is not very good idea for monolith architecture
# Example demo
# Another small trick:
- When we use token based authentication? When the frontend domain and backend domain are different
- When we use session based authentication? When the frontend domain and backend domain are same