Product Information & Backend-for-Frontend (BFF) Architecture
What is a backend-for-frontend (BFF) and how does it help with modern application development?
A backend-for-frontend (BFF) is a dedicated backend layer for each frontend application (such as web, mobile, or desktop). It fetches, filters, and structures data from microservices, ensuring each client receives only the data it needs. This approach prevents under- or over-fetching, reduces network calls, and separates concerns, making frontend development more efficient and secure. Learn more.
How does GraphQL support backend-for-frontend (BFF) architectures?
GraphQL enables clients to request exactly the data they need, avoiding under- or over-fetching. Its flexible query structure and built-in documentation make it ideal for BFFs, allowing each frontend to define its own data requirements and receive tailored responses. This makes GraphQL a perfect fit for BFF implementations. Read more.
What is Hygraph and how does it relate to GraphQL and BFFs?
Hygraph is a federated content platform and the first GraphQL-native Headless CMS. It allows developers to unify data from multiple sources, structure it for specific use cases, and distribute it globally. Hygraph's API uses GraphQL, making it an ideal backend for BFF architectures by enabling flexible, efficient, and secure content delivery. Learn more.
How do you build a backend-for-frontend (BFF) using Hygraph?
To build a BFF with Hygraph, you create a content model (e.g., BlogPost), connect remote data sources (such as Hashnode's GraphQL API), and secure your API with authentication tokens. You can then use GraphQL clients like Apollo to query and mutate data, tailoring responses for each frontend. See the full tutorial.
What are the main advantages of using a BFF with Hygraph?
Using a BFF with Hygraph ensures no under- or over-fetching of data, reduces network calls, separates concerns between frontend and backend, and allows for secure, efficient, and flexible content delivery tailored to each client application. Learn more.
How do you secure the Hygraph Content API when building a BFF?
Hygraph's Content API requires authentication. You secure it by creating a Permanent Auth Token in the project settings, assigning permissions (read, create, publish) to your content models, and using the token in your GraphQL client for authorized access. See details.
What tools and accounts do you need to follow the Hygraph BFF tutorial?
To follow the Hygraph BFF tutorial, you need a Hygraph account, a Hashnode account with blog posts, and a GraphQL client such as ApolloGraphQL. See requirements.
How do you connect remote data sources to Hygraph for BFF use cases?
You can add remote sources in Hygraph's schema settings, specifying the external GraphQL API endpoint (e.g., Hashnode API). This allows Hygraph to fetch and federate data from multiple sources, making it available through a single backend for your frontend applications. Learn more.
How do you model content in Hygraph for a BFF scenario?
You create content models (such as BlogPost) in the Hygraph dashboard, define fields (like slug), and connect remote sources or fields as needed. This flexible modeling allows you to tailor the backend to the needs of each frontend application. See the guide.
How do you interact with Hygraph as a BFF using GraphQL clients?
You use GraphQL clients like Apollo to connect to the Hygraph Content API, authenticate with your token, and perform queries and mutations. This allows you to fetch, create, and publish content programmatically, customizing responses for each frontend. See code examples.
Can you extend Hygraph BFF implementations to aggregate data from multiple blogging platforms?
Yes, you can add additional remote sources (such as Forem's DEV API) to Hygraph and aggregate data like blog post likes from multiple platforms, storing and serving them from Hygraph to your frontend. Learn more.
What are the key features of Hygraph that support BFF and content federation?
Hygraph offers content federation, remote source integration, digital asset management, localization, and a globally distributed CDN. These features enable you to unify, manage, and deliver content efficiently for BFF scenarios. See more.
How does Hygraph handle performance for BFF and content delivery use cases?
Hygraph provides high-performance endpoints designed for low latency and high read-throughput content delivery. The platform actively measures GraphQL API performance and offers best practices for optimization. Read about performance improvements.
What integrations does Hygraph support for BFF and content federation scenarios?
Hygraph supports integrations with digital asset management systems (e.g., Aprimo, AWS S3, Bynder, Cloudinary, Imgix, Mux, Scaleflex Filerobot), as well as other tools like Adminix and Plasmic. Developers can also build custom integrations using SDKs and connect external APIs via REST and GraphQL. See all integrations.
What APIs does Hygraph provide for BFF and content management?
Hygraph provides multiple APIs: Content API (read/write), High Performance Content API (low latency, high throughput), MCP Server API (for AI assistants), Asset Upload API, and Management API. These APIs support a wide range of BFF and content federation use cases. See API documentation.
Where can I find technical documentation for building BFFs with Hygraph?
Hygraph offers comprehensive technical documentation, including API references, schema components, webhooks, and AI integrations. Access all resources at Hygraph Documentation.
What is the primary purpose of Hygraph and how does it address BFF needs?
Hygraph empowers businesses to create, manage, and deliver digital experiences at scale. Its GraphQL-native architecture, content federation, and flexible modeling make it ideal for BFF scenarios, supporting efficient workflows and seamless integration with modern tech stacks. Learn more.
How easy is it to get started with Hygraph for BFF projects?
Hygraph offers a free forever developer account, an API playground for immediate exploration, structured onboarding, and extensive documentation. Case studies show projects can launch in as little as 2 months. See Top Villas case study.
What feedback have customers given about Hygraph's ease of use for BFF and content federation?
Customers praise Hygraph's intuitive UI, ease of setup, and ability for non-technical users to manage content independently. Real-time changes and custom app integrations further enhance usability. See user feedback.
Pricing & Plans
What pricing plans does Hygraph offer?
Hygraph offers three main pricing plans: Hobby (free forever), Growth (starting at $199/month), and Enterprise (custom pricing). Each plan is designed for different team sizes and project needs. See pricing details.
What features are included in the Hygraph Hobby plan?
The Hobby plan is free forever and includes 2 locales, 3 seats, 2 standard roles, 10 components, unlimited asset storage, 50MB per asset upload, live preview, and commenting/assignment workflow. See full feature list.
What features are included in the Hygraph Growth plan?
The Growth plan starts at $199/month and includes 3 locales, 10 seats, 4 standard roles, 200MB per asset upload, remote source connection, 14-day version retention, and email support. See full feature list.
What features are included in the Hygraph Enterprise plan?
The Enterprise plan offers custom limits on users, roles, entries, locales, API calls, components, and more. It includes advanced features like scheduled publishing, dedicated infrastructure, SSO, multitenancy, instant backup recovery, custom workflows, and dedicated support. See full feature list.
Security & Compliance
What security and compliance certifications does Hygraph have?
Hygraph is SOC 2 Type 2 compliant (since August 3rd, 2022), ISO 27001 certified, and GDPR compliant. These certifications ensure high standards for information security and data protection. See details.
What security features does Hygraph offer for BFF and enterprise use cases?
Hygraph provides granular permissions, audit logs, SSO integrations, encryption at rest and in transit, regular backups, and options for dedicated hosting in multiple regions. See all security features.
Use Cases & Customer Success
Who can benefit from using Hygraph for BFF and content federation?
Hygraph is ideal for developers, product managers, content creators, marketers, solutions architects, enterprises, agencies, eCommerce platforms, media companies, technology firms, and global brands needing scalable, flexible content management. See case studies.
What industries use Hygraph for BFF and content federation?
Industries include SaaS, marketplaces, education technology, media and publishing, healthcare, consumer goods, automotive, technology, fintech, travel, food and beverage, eCommerce, agencies, gaming, events, government, consumer electronics, engineering, and construction. See all industries.
What business impact can customers expect from using Hygraph for BFF?
Customers report improved operational efficiency, faster speed-to-market, reduced costs, enhanced scalability, and better customer engagement. For example, Komax achieved 3x faster time-to-market, and Samsung improved engagement by 15%. See business outcomes.
Can you share specific case studies of customers using Hygraph for BFF or content federation?
Yes. Samsung built a scalable API-first application, Komax managed 20,000+ product variations across 40+ markets, and Voi scaled multilingual content across 12 countries. See all case studies.
Who are some of Hygraph's customers for BFF and content federation?
Notable customers include Samsung, Dr. Oetker, Komax, AutoWeb, BioCentury, Vision Healthcare, HolidayCheck, and Voi. See customer stories.
Competition & Differentiation
How does Hygraph compare to other CMS and BFF solutions?
Hygraph is the first GraphQL-native Headless CMS, offering content federation, user-friendly tools, enterprise-grade features, and proven ROI. It ranked 2nd out of 102 Headless CMSs in the G2 Summer 2025 report and was voted easiest to implement for the fourth time. See G2 report.
What makes Hygraph different from traditional CMS platforms?
Unlike traditional CMS platforms that rely on REST APIs, Hygraph uses a GraphQL-native architecture, supports content federation, and provides a flexible, scalable, and modern approach to content management. Learn more.
How does Hygraph address common pain points in BFF and content management?
Hygraph eliminates developer dependency, modernizes legacy tech stacks, ensures content consistency, reduces operational costs, accelerates speed-to-market, and simplifies integration with third-party systems. See case studies.
What pain points does Hygraph solve for BFF and content federation users?
How to use GraphQL to build backend-for-frontends (BFFs)
In this article, you'll learn about backend-for-frontend architecture by building a backend-for-frontend to serve blog posts from Hygraph.
Written by AnshumanÂ
on Dec 07, 2022
Building a backend to serve multiple clients—mobile, web, and desktop—can get complicated over time. The requirements and capabilities of these clients can differ significantly, and accommodating them all can leave your backend bloated. For mobile apps, this can cause a decline in performance due to over-fetching unnecessary data, while devices with larger screens may suffer from under-fetching data, forcing the application developers to filter and format the data best suited for each client. These added responsibilities and computing requirements on the frontend make it harder to adapt to rapid development and changes.
One solution to this problem is creating a layer of backend-for-frontends. In this design, each frontend application has a dedicated backend responsible for fetching the resources from microservices and returning the proper response for this specific client. Backend-for-frontends do all the fetching, filtering, and structuring for the data requested, so the frontend applications get the exact data they asked for—nothing more, nothing less.
In this article, you'll learn about backend-for-frontend architecture by building a backend-for-frontend to serve blog posts from Hygraph. While doing so, you'll model your application's data and use remote data sources behind a backend-for-frontend. You'll get a deeper understanding of GraphQL, its advantages, and how it can serve as a backend-for-frontend with Hygraph.
BFFs sit in the middle of the micro-services and frontend applications, as shown in the following image.
BFFs customize the response and error handling specific to each client application so the frontend applications don't have to. By doing so, BFFs enhance the architecture and provide the following advantages over traditional backends:
No under/over-fetching: By serving every client based on its specific requirements, BFFs ensure that the client gets what they need and nothing more. By doing this, BFFs save network bandwidth and reduce the risk of exposing sensitive information to clients.
Separation of concerns: Using a layer of BFFs relieves the frontend from needing to format data, which allows developers flexibility in choosing and structuring their microservices, without the need to change the frontend. Clients usually don't need to be changed when a microservice is replaced or changes its API contract, because the BFFs are responsible for ensuring resilient APIs.
Fewer network calls: Because BFFs can fetch the data from multiple resources at once, the client doesn't have to make multiple calls to get all the information. A good example of this is fetching nested information, such as a blog post that contains an author. The BFF can return the author's data with the blog post rather than forcing the client to first request the blog post, then request the author data associated with it.
GraphQL is a query language that simplifies your API by representing the business model as graphs. Graphs define the data structure as objects and how they relate, similar to how humans perceive information. Because of this, the query and its response have identical structures, making it easier to understand and access information. GraphQL provides complete API documentation straight out of the box, and enables developers to structure their queries in the way best suited for the application. GraphQL's query implementation puts the control in the hands of the client to ask for granular data, ensuring there's no under- or over-fetching. The ability to request data with this granularity makes GraphQL a perfect BFF solution.
Hygraph is a federated content platform that enables developers to unify data from different sources, structure it the way that works for their specific use case, and distribute it to any platform worldwide. As the name suggests, Hygraph's API uses GraphQL, which comes with documentation that makes it simpler to understand the API data model and how different data nodes relate to each other. Hygraph offers numerous features such as digital asset management to store and serve optimized media content, and remote sources to connect multiple data sources to Hygraph, allowing the clients can read from a single backend.
On the dashboard, create a new project by selecting the Blank tile from the list.
Give your new project a name and description, then click on the Create project button.
When the project has been created, open the Schema page by clicking the icon on the left navigation. On the Schema page, click on the Add button next to Models, which will bring up a pop-up. Give your model a display name of "Blog post", an API ID of "BlogPost", and a plural API ID of "BlogPosts", then click Create Model to create the BlogPost content model.
Select the Blog post model from the left navigation. Now, add a new Single line text field from the right pane and name it "slug". You'll use this field to store the blog post's slug.
Access Hashnode API Using Remote Sources
On the Schema page, click the Add button next to Remote Sources to add Hashnode's GraphQL API as a remote source. Give it a display name of "Hashnode API", and the prefix of "HashnodeAPI". Set the type to GRAPHQL, and the base URL as https://api.hashnode.com, which is the API endpoint for Hashnode. Click Create in the top right corner of the screen.
Return to the Blog post model page, and add a new GraphQL field from the right-hand pane. In the form's Query section, select the Post query, and add {{doc.slug}} to reference the slug for the document. Add the hostname for your Hashnode account, which will allow Hygraph to dynamically fetch the blog content from the blog post’s slug.
Secure the Hygraph API
By default, the Hygraph Content API rejects unauthenticated requests. To securely access the Content API, you must create a Permanent Auth Token on the Settings page.
Open the Settings page through the cog icon near the bottom of the left-hand panel. In the Permanent Auth Tokens section, click the Create token button.
Create a new token with the name "Blog post token", and select Published as the default stage for content delivery, then click Create & configure permissions.
On the token permissions page, copy and save the token value for later usage, then click the Create permission button.
The Create permission form will pop up. Select the Blog post model, and assign the following permissions:
Read: Locales: All; Stages: All
Create: Locales: All
Publish: Locales: All; From stages: All; To stages: All
Click on the Create button to save permissions.
With the security measures in place, no one can access the content without the authorized token, and the token is only authorized to read, create, and publish content.
Interacting With the BFF
Hygraph uses GraphQL queries and mutations for reading and updating content. Hygraph prepares a default set of queries and mutations for each data model you create to allow simple workflows such as reading, writing, or publishing. You modify these premade queries to suit your use case, or you can also create your own from scratch.
You can use the Hygraph playground section to explore the documentation that Hygraph generated based on the schema. You can also prepare queries and mutations and test them before using them in your application.
You'll need a GraphQL client, such as ApolloGraphQL, to use Hygraph as a BFF.
The following example uses ApolloGraphQL to connect to the Hygraph BFF in any JavaScript application.
Begin by navigating again to the Settings page on your Hygraph dashboard, then to the Endpoints page. Copy the Content API endpoint.
Inside the project, run yarn add @apollo/client graphql to install the GraphQL client dependencies.
Create a new file called ./apollo-client.js, and add the following code to connect to the Apollo GraphQL client. Use the Content API endpoint copied above as the uri, and the permanent authorization token in the authorization value.
// replace this with the permanent authorization token copied above
authorization:`Bearer ${process.env.AUTH_TOKEN}`,
},
};
});
const client =newApolloClient({
link: authLink.concat(httpLink),
cache:newInMemoryCache(),
});
exportdefault client;
Use the GraphQL client's query function with the gql expression to query the blog posts. Notice how you can select different fields based on the application requirements. For example, the code below requests only the title field in the blogContent remote source field of published blog posts.
importclientfrom"../../apollo-client";
import{ gql }from"@apollo/client";
asyncfunctiongetPublishedBlogPosts(){
const{ data }=await client.query({
query: gql`
query getBlogBySlug {
blogPosts(stage: PUBLISHED) {
slug
blogContent {
title
}
}
}
`,
});
return data
}
You can easily fine tune the required fields in the gql query to suit your client's needs.
To add a new blog post, use the GraphQL client’s mutate function. The following example creates a new post and publishes the newly created blog post:
You've successfully built a BFF using Hygraph. In doing so, you've learned about content modeling, federation, and distribution with Hygraph, as well as how to secure this content. You've also learned about GraphQL and its advantages for data fetching, and how to use GraphQL to serve content from Hygraph as a BFF.
You can extend the example above to add more remote sources for blogs, such as Forem'sDEV API. You can also collect the likes from all blogging platforms, store them in the blog post, and serve them from Hygraph to your blog.
Hygraph is a federated content platform with an intuitive data modeling and distribution API. It offers localization, remote sources, digital asset management, and many other features straight out of the box. Its globally distributed CDN makes it highly performant for serving both assets and information. Sign up for a free account today to get started.
Blog Author
Anshuman Bhardwaj
Anshuman is a seasoned software engineer who loves writing and teaching. A craftsman of React and JavaScript, he enjoys solving everyday problems with code and sharing his learnings with the world.
Share with others
Sign up for our newsletter!
Be the first to know about releases and industry news and insights.