---
title: "Backend for Frontend (BFF) Pattern — Definition & Engineering Context"
description: "The Backend for Frontend (BFF) pattern is an API design strategy that creates a dedicated backend service for each type of frontend client (web, mobile, IoT), optimizing data fetching and response shaping for each client's specific needs."
canonical: https://erpstack.io/glossary/bff-pattern
markdown_url: https://erpstack.io/glossary/bff-pattern.md
publisher: ERPStack
---

# Backend for Frontend (BFF) Pattern

> **Definition:** The Backend for Frontend (BFF) pattern is an API design strategy that creates a dedicated backend service for each type of frontend client (web, mobile, IoT), optimizing data fetching and response shaping for each client's specific needs.

## In depth

A single universal API often over-fetches data for mobile clients (which need minimal fields) and under-fetches for admin dashboards (which need nested relations). BFF creates separate Next.js API route groups — /api/web/* for the web portal, /api/mobile/* for the React Native app — each fetching and shaping data specifically for its consumer. This dramatically reduces mobile network payload and eliminates client-side data transformation logic.

## How ERPStack applies this

We implement BFF patterns using Next.js Route Groups and tRPC router namespaces, allowing mobile apps and web dashboards to share the same PostgreSQL backend while receiving optimized, client-specific response shapes.

## Related reading

- [API-First Development](https://erpstack.io/glossary/api-first)
- [GraphQL API Schema](https://erpstack.io/glossary/graphql)
- [tRPC Protocol](https://erpstack.io/glossary/trpc)
