Backend For Frontend

The translation layer that
makes everything smoother

A Backend for Frontend (BFF) is a dedicated API layer built exclusively to serve a single user interface, whether that is your mobile or web application. It works like a personal concierge: instead of forcing your application to query multiple backend systems, the BFF collects and packages exactly what your app needs in a single request.

The issue

Why a generic API does
not work for apps

Suppose you have a monolithic backend that was once built for the web app. That API returns large JSON objects with dozens of fields, because the web app needs them. Your mobile app only needs three.

The result: over-fetching, under-fetching, and a mobile app that depends on the capacity planning of a backend team with other priorities. A BFF solves this. It is a thin, fast service that composes exactly the data the app needs. No more, no less.
Architecture

How a BFF is structured

Pattern
API Aggregation
Orchestration
The BFF calls multiple downstream services and combines the responses into one optimized payload for the app. Fan-out with parallel calls, fan-in to one response.
Protocol
GraphQL as BFF layer
Apollo Server · Pothos · DataLoader
GraphQL is an excellent choice for BFFs: the app asks for exactly what it needs, the BFF resolves queries through existing REST services. DataLoader prevents N+1 problems.
Protocol
REST BFF
Express · Fastify · Hono
When GraphQL is overkill: a lean REST BFF built with Fastify or Hono. Endpoint per screen, clear contracts, easy to cache and monitor.
Caching
Response Caching
Redis · In-memory · CDN Edge
The BFF is the ideal place for caching. Frequently requested data is cached in Redis or in-memory. Static responses are edge-cached via CDN for minimal latency.
Auth
Authentication Gateway
JWT · OAuth2 · Session tokens
The BFF validates tokens before requests go downstream. One place for auth logic, not spread across ten services. Token translation for legacy systems.
Resilience
Circuit breaker & Retry
opossum · p-retry · timeouts
When a downstream service fails, the circuit breaker cuts off calls and returns cached or empty data. The app remains functional, even when the backend is struggling.
Our BFF stack

What we frequently use

Runtime
Node.js · Bun
Subtitle
Node.js for most projects because of the ecosystem. Bun for projects where raw performance makes the difference.
Framework
Fastify · Hono · Apollo
Subtitle
Fastify for high-performance REST BFFs. Hono for edge deployment. Apollo Server for GraphQL BFFs.
Type safety
TypeScript · Zod · tRPC
Subtitle
TypeScript throughout the stack. Zod for runtime validation of requests and responses. tRPC for type-safe end-to-end contracts between BFF and app.

A BFF is not an extra layer of overhead.
It is the boundary that prevents your app team from waiting on the backend team.

Cases

BFF in practice