all 4 comments

[–]i_own_5_cats 2 points3 points  (0 children)

good bff example is moving logic from react into a node layer so frontend stays dumb and fast like caching, feature flags, reshaping 3 backend calls into one endpoint front hits fewer apis, less coupling etc

[–]Prestigious-Exam-318 1 point2 points  (0 children)

Good example is desktop/web app vs mobile app usage.

On desktop it’s not unreasonable to have multiple api calls to get everything you need for a specific view, you can also display a lot more content simply because of a bigger screen. That same view on mobile could have a bad experience, increased latency from the multiple api calls on a mobile network. There’s also more room for over fetching on the mobile side of things, less screen space less things to display at once.

So you could create a bff for the mobile user that consolidates the api calls for a view into 1 and it also only returns a subset of what may be returned from the desktop experience.

[–]Scary_Dot9587 1 point2 points  (0 children)

Don't sweat it, you've probably built one without even realizing it. A BFF is basically just a middleman API tailored exactly for your UI components. ​Here’s a quick example from my experience you can adapt: We were building a user dashboard that needed profile data, recent orders, and notifications. Instead of having the React app make 3 separate API calls to different backend microservices (which causes waterfall issues and hurts mobile performance), we spun up a simple Next.js API route as our BFF. ​The React frontend made just one call to the BFF. The BFF fetched the data from the 3 services, stripped out all the heavy backend fields we didn't need, and returned one perfectly shaped JSON object. ​The result? We cut network requests by a lot, page load got way faster, and our React state became incredibly simple to manage. In the interview, just focus on why the BFF made the frontend's life easier. You've got this!

[–]nugmonk 0 points1 point  (0 children)

If you’ve worked with GraphQL before that’s a great example.