image de chargement
Back to glossary

BFF (Backend for Frontend)

Architectural pattern creating dedicated backend APIs for each frontend client type, optimizing performance and user experience.

Updated on January 8, 2026

Backend for Frontend (BFF) is an architectural pattern that involves creating a specific backend layer for each type of user interface (web, mobile, IoT). Rather than a single generic backend serving all clients, each BFF adapts and optimizes data and logic for its frontend's specific needs. This approach solves over-fetching, under-fetching, and client complexity issues inherent to monolithic APIs.

BFF Pattern Fundamentals

  • Separation of concerns: each BFF is tailored for its specific client (mobile iOS, Android, desktop web, etc.)
  • Intelligent aggregation: the BFF orchestrates calls to backend microservices and composes optimal responses
  • Decoupling: frontend teams can evolve their BFF without impacting other clients or backend services
  • Targeted performance: payload optimization, cache management, and business logic adapted to usage context

Business and Technical Benefits

  • Reduced frontend complexity: orchestration and transformation logic moved server-side
  • Improved performance: optimized payloads reduce bandwidth and accelerate loading times
  • Team autonomy: each frontend team controls its API contract without cross-dependencies
  • Differentiated user experience: fine-tuned adaptation to each platform's constraints (mobile network, screen size)
  • Facilitates evolution: progressive migration possible without global refactoring, isolated testing per client

Concrete BFF Architecture Example

mobile-bff.ts
// BFF for mobile application - optimized for mobile network
import { Router } from 'express';
import { UserService } from './services/user';
import { OrderService } from './services/order';
import { ProductService } from './services/product';

const mobileBFF = Router();

// Optimized endpoint for mobile dashboard
mobileBFF.get('/dashboard', async (req, res) => {
  const userId = req.user.id;
  
  // Parallel aggregation from multiple microservices
  const [user, recentOrders, recommendations] = await Promise.all([
    UserService.getProfile(userId, { fields: 'name,avatar,tier' }),
    OrderService.getRecent(userId, { limit: 3, summary: true }),
    ProductService.getRecommendations(userId, { count: 5, imageSize: 'thumb' })
  ]);
  
  // Optimized payload for mobile (essential data only)
  res.json({
    user: {
      displayName: user.name,
      avatarUrl: user.avatar,
      loyaltyTier: user.tier
    },
    recentActivity: recentOrders.map(order => ({
      id: order.id,
      status: order.status,
      total: order.total,
      itemCount: order.items.length
    })),
    suggestedProducts: recommendations.map(p => ({
      id: p.id,
      name: p.name,
      price: p.price,
      image: p.thumbnailUrl // Mobile-optimized image
    }))
  });
});

export default mobileBFF;
web-bff.ts
// BFF for web application - richer payloads
import { Router } from 'express';
import { UserService } from './services/user';
import { OrderService } from './services/order';
import { AnalyticsService } from './services/analytics';

const webBFF = Router();

// Same functionality, optimized for desktop web
webBFF.get('/dashboard', async (req, res) => {
  const userId = req.user.id;
  
  const [user, orders, analytics, recommendations] = await Promise.all([
    UserService.getProfile(userId, { fields: 'all' }),
    OrderService.getRecent(userId, { limit: 10, detailed: true }),
    AnalyticsService.getUserStats(userId),
    ProductService.getRecommendations(userId, { count: 12, imageSize: 'large' })
  ]);
  
  // Enriched payload for web (charts, complete history)
  res.json({
    user: user, // Complete profile
    orders: orders, // Extended details
    analytics: {
      monthlySpending: analytics.spending,
      categoryBreakdown: analytics.categories,
      savingsThisYear: analytics.savings
    },
    recommendations: recommendations // HD images
  });
});

export default webBFF;

Implementing a BFF

  1. Identify distinct clients: analyze web, mobile iOS/Android, tablets, partner APIs to determine required number of BFFs
  2. Define API contracts: design endpoints adapted to each client's specific needs (data, format, performance)
  3. Implement orchestration: create aggregation logic for backend microservices with error handling and fallbacks
  4. Optimize per client: adjust cache, compression, pagination based on network and device constraints of each platform
  5. Monitor and iterate: instrument each BFF with metrics (latency, error rate) for continuous optimization

Expert Tip

Don't create a BFF for every minor client variant. Group clients with similar needs (e.g., iOS and Android can share the same mobile BFF). Maintaining multiple BFFs has a cost - prefer 2-4 well-designed BFFs rather than 10 variants. Use feature flags for minor variations within the same BFF.

Associated Tools and Technologies

  • GraphQL with Apollo Federation: modern alternative to BFF allowing client to compose queries
  • Node.js / Express: lightweight stack ideal for implementing performant BFFs with async handling
  • API Gateway (Kong, AWS API Gateway): can host and route to multiple BFFs with centralized authentication
  • OpenAPI / Swagger: documentation for API contracts specific to each BFF
  • gRPC: performant communication between BFF and backend microservices
  • Redis: shared cache to optimize frequent aggregated responses

The BFF pattern represents a strategic investment for multi-platform organizations. By aligning backend architecture with client diversity, it accelerates development cycles, improves user experience quality, and reduces technical debt. The key to success lies in balancing specialization (truly adapting to client needs) and mutualization (avoiding excessive duplication). Well implemented, the BFF becomes an innovation accelerator enabling teams to rapidly deliver differentiated experiences across each channel.

Themoneyisalreadyonthetable.

In 1 hour, discover exactly how much you're losing and how to recover it.