Backend-for-Frontend (BFF): The Tiny Butler Standing Between Your App and Total Chaos

Sora

If you have ever built an app that has both a web UI and a mobile UI, you have probably met this situation:

  • The web app wants 47 fields, sorting options, and a filter panel that could qualify as a second mortgage application.
  • The mobile app wants 6 fields, fast responses, and a payload small enough to fit in a carry-on bag.
  • Your single API is in the middle like: “I can be everything to everyone!” (Famous last words.)

A Backend-for-Frontend (BFF) is the pattern that says: “Stop making one backend do interpretive dance for every client. Give each client its own friendly little backend.”

Microsoft describes the pattern as creating separate backend services tailored to specific frontends so you do not keep customizing one backend for multiple interfaces. It is explicitly based on Sam Newman’s BFF pattern. References: Azure Architecture Center — Backends for Frontends, Sam Newman — BFF pattern


What it is

A BFF is a server-side component that exists specifically to serve one frontend experience (web, iOS, Android, desktop, TV app, toaster with a screen, etc.). It can:

  • Shape responses into exactly what that frontend needs
  • Aggregate calls to multiple services so the frontend does not have to juggle 12 network requests
  • Hide internal service details so clients do not couple to them
  • Apply client-specific auth, caching, rate limits, and “please do not melt my database” logic

Think of it like a translator and concierge in one: it speaks frontend fluently, and it knows where the backend bodies are buried.

Reference: microservices.io — API Gateway / BFF


Is it still relevant?

Yes. It keeps showing up in mainstream architecture guidance (cloud pattern catalogs, microservices patterns, and SPA security discussions). Microsoft still actively documents it (updated May 14, 2025), and microservices.io lists it alongside API gateway patterns.

Also: modern frontends are messy. You have SPAs, mobile apps, micro-frontends, and third-party integrations all competing for the same data. A BFF is basically a peace treaty.


Pros, cons, strengths, weaknesses

The good stuff

  • Frontend-friendly APIs: Each UI gets exactly what it needs. No more “mobile downloads the entire solar system because the web app wanted pagination metadata.”
  • Less frontend complexity: The BFF can aggregate multiple backend calls, so the frontend does not become a distributed systems engineer by accident.
  • Faster iteration per client: A mobile team can adjust the BFF without negotiating with the web team, the API team, and the Committee for Unnecessary Meetings.
  • Security benefits for browser apps: Some BFF approaches keep OAuth/OIDC tokens off the browser and handle those flows server-side.
NightCafe

The trade-offs

  • More services to run: Congratulations, you adopted a pattern that creates more things. You now own more deployments, monitoring, and logs.
  • Risk of duplicated logic: If every BFF re-implements the same transformations, you will eventually have five versions of “formatPhoneNumber()” and they will all disagree.
  • Can become a dumping ground: If you let it, the BFF turns into the sock drawer of your architecture: auth, caching, orchestration, business logic, three old receipts, and one mysterious key.

Sam Newman even calls out the tension around putting generic perimeter concerns in a BFF versus an upstream layer, because extra layers add latency and complexity.


What it is used for

Common BFF use cases:

  • One product, multiple clients: web + mobile + desktop + partner API
  • Microservices integration: the BFF fans out to multiple services, then returns one clean response
  • Performance tuning per device: mobile gets fewer fields, compressed payloads, aggressive caching; web gets richer payloads
  • Micro-frontend architectures: each frontend slice can have a BFF that speaks its language

Microsoft’s microservices guidance describes it as a way to keep backend services simple by separating client-specific concerns.


A concrete example

Let’s say you have services like:

  • Orders
  • Catalog
  • Pricing
  • User

Your web frontend needs a dashboard with orders, line items, pricing breakdowns, and recommendations.

Your mobile frontend needs:

  • the last 5 orders
  • an order status
  • a single “buy again” button

If both hit one general-purpose API, you end up either:

  • bloating responses for everyone, or
  • building endless query params until your API looks like a tax form.

With BFF:

  • web-bff returns a rich dashboard payload
  • mobile-bff returns a lean payload with fast caching and minimal fields

Tiny pseudo-example (Node/Express style)

app.get("/mobile/orders", async (req, res) => {
const userId = req.user.id;

const orders = await ordersSvc.getRecentOrders(userId, { limit: 5 });
const shaped = orders.map(o => ({
id: o.id,
status: o.status,
total: o.total,
buyAgainSku: o.items?.[0]?.sku ?? null
}));
res.json({ orders: shaped });
});

Notice what is missing:

  • 20 fields the mobile UI will never render
  • 12 calls from the phone to 12 microservices
  • frontend developers quietly aging in real time
Gemini

Alternatives (and how they compare)

  • Single API for all clients: Simple at first, then it becomes a “one menu feeds all dietary needs” situation.
  • API Gateway only: Great as a single entry point, but not always great at deep client-specific shaping. (Some teams combine API gateway + BFF, where the BFF is a specialized gateway per client type.)
  • GraphQL: Can reduce over/under-fetching by letting clients shape queries, but it can move complexity into query design, caching, and backend resolvers. (Not “bad”, just a different flavor of pain.)
  • Shared aggregation service: Works until every client needs a slightly different aggregation, and then you reinvent… BFF.

History and who invented it

The BFF pattern is widely attributed to Sam Newman, and he wrote about it as a microservice pattern in November 2015. Microsoft’s BFF pattern page also notes that their description is based on Newman’s pattern.


Famous art?

Not really. No museum wing is dedicated to “A Study in Slightly Different JSON Shapes.”

But if someone ever paints it, I hope it is a dramatic oil portrait of a tiny butler standing between two angry clients, holding a tray labeled “payload normalization,” while the backend screams in the distance.


Popularity and trend direction

There is no single official scoreboard for “patterns people quietly use a lot,” but the signals are strong:

  • It is a named pattern in major cloud architecture catalogs (Microsoft).
  • It remains a core idea in microservices pattern references.
  • It is increasingly discussed as a security-friendly approach for SPAs by moving OAuth/OIDC protocol interactions server-side.

If anything, BFF has evolved from “performance and aggregation” into “performance, aggregation, and security sanity.”


Does it work well with AI?

Yes, and in two practical ways:

  1. AI features usually need orchestration: calling an LLM, retrieving data (RAG), shaping the response, enforcing policy, caching, rate-limiting, and logging. A BFF is a natural place to do that orchestration without dumping it into the client.
  2. Clients want different AI outputs: web might want citations and expandable detail; mobile might want a short summary and a button. Different BFFs can shape the same AI result into different UX.

Deep Dream Generator

Tech stacks it works with

A BFF is not picky. It will work with:

  • Node.js (Express/Fastify)
  • .NET (Minimal APIs)
  • Java (Spring Boot)
  • Go
  • Python (FastAPI)
  • Anything that can listen to HTTP and feel responsible for other peoples happiness

On the frontend side, it pairs nicely with React, Angular, Vue, and mobile apps.

If you are specifically thinking about browser security and auth flows, BFF frameworks exist that focus on handling OAuth/OIDC server-side.


Tools that commonly show up with BFF

  • Reverse proxies and edge: Nginx, Envoy
  • API tooling: gateways, rate limiting, caching
  • Observability: OpenTelemetry, centralized logging, tracing
  • Cloud deployment: containers, serverless (sometimes), managed gateways

AWS also discusses the BFF pattern in the context of frontend web and mobile architectures.


One last interesting tidbit

The BFF pattern is like adopting a pet.

At first it is adorable and solves problems. Then you realize it needs:

  • monitoring
  • alerting
  • deployments
  • and a name

Name your BFFs like you name pets: something you do not mind yelling at 2 a.m.


Want more?

If you have built (or inherited) a BFF, drop a comment with your best war story. Bonus points if your BFF started as a “thin layer” and later gained opinions, a personality, and a throne.


Art Prompt (Rococo):

A sun-drenched garden scene bursting with playful elegance and theatrical charm, rendered with airy, feathery brushwork and luminous pastel tones. A central figure in elaborate, swirling silk attire arcs through the air on a delicately ornamented swing, suspended from flowering branches and wrapped in ribbons. Surround the figure with soft, billowing foliage and clusters of roses and jasmine, painted in creamy pinks, pale peaches, and misty greens, with hints of powder blue and warm gold catching the light. Add subtle visual comedy through tiny details: a mischievous lapdog mid-leap, a fluttering shoe, and scattered petals caught in a gentle breeze. The composition should feel romantic and buoyant, with light filtering through leaves in sparkling highlights, soft shadows, and a dreamy, slightly mischievous mood. No text, no logos, no harsh edges, and no modern objects.


Video Prompt

Cinematic vertical shot with graceful, playful motion: begin with a slow drift through sunlit leaves and pastel blossoms, then reveal the ornate swing in a gentle, floating push-in. Animate soft wind rippling silk fabric and ribbons, petals spiraling in the air, and dappled light shimmering across the scene. Add subtle comedic micro-moments: the tiny dog hopping once in slow motion, a shoe spinning lightly before landing off-frame, and a quick sparkle of reflected sunlight on gold trim. Use smooth parallax depth, slow-motion accents on the swing arc, and a final dreamy pull-back as petals continue to swirl. Keep the look painterly and luminous, with soft focus transitions and warm, romantic color grading. No text or captions.

Songs to pair with it

  • Ocean Drive — Duke Dumont
  • Lovesong — The Cure

Follow for more, and if this made you grin even once, leave a comment with the most ridiculous thing you have ever shipped to production “temporarily.”