Technical document

Implementation Design for Creating BFF Boundaries with React Router and Hono

We will organize where to place the boundaries for BFF, authentication, types, and error handling in a configuration that combines React Router's screen implementation with Hono API.
Architecture / BFF~10 minPublication Date September 22, 2026Update date September 22, 2026
Implementation Design for Creating BFF Boundaries with React Router and Hono

Summary

Key points of this document

  • Where are the design challenges?
  • How to define boundaries
  • Effective implementation details

Overview

In configurations where the frontend and API can be written in the same TypeScript, boundaries tend to become ambiguous. When placing a BFF, it's crucial not to mix screen-specific aggregation with the responsibilities of business APIs. The more a configuration allows writing screens and APIs in the same TypeScript, the more both the convenience of type sharing and the risk of responsibility leakage emerge simultaneously.

Where are the design challenges?

In a configuration where Hono API is called from React Router's loader or action, the problem is where to aggregate multiple data required for the screen. Spreading API calls on the screen side complicates state management, and putting too much screen-specific processing on the API side makes it difficult to reuse.

BFFs are convenient, but they tend to accumulate responsibilities such as authentication, authorization, caching, and error transformation. Especially when there are admin screens and user screens, it's necessary to decide early on whether to use the same API or separate BFFs for each screen.

React Router's loader makes it easy to collect data needed for the screen, and Hono is a combination that makes it easy to create lightweight API boundaries. On the other hand, if the loader directly holds too much domain knowledge, screen transitions and business rules become intertwined, making testing and reuse difficult.

How to define boundaries

The Hono side provides domain-unit APIs, which are aggregated for screens on the React Router side or in the BFF layer. The BFF handles the call order of multiple APIs, conversion to display DTOs, and light caching, while the core of DB updates and authorization decisions remains on the business API side.

Boundaries are considered in three layers: screen-specific aggregation, business rules, and persistence. The BFF handles multiple API calls, display DTOs, and UI decisions upon partial failure, while the Hono side maintains the contract for business operations against authenticated principals.

Effective implementation details

In TypeScript, we separate DB schema types, API response types, and screen display types. Requests passed from BFF to Hono include not only the user ID but also permission scopes and information necessary for auditing. Errors are handled separately as HTTP status, user-facing messages, and internal log codes.

For type sharing, instead of exporting DB types directly,ApiResponse,BffViewModel,FormInputare separated. The Hono side validates input with Zod, etc., and even if the React Router side uses the same schema, formatting for error display is confined to the screen.

  • In loaders, perform read aggregation, and move update-related side effects to actions or API handlers.
  • Include user ID, permission scope, and search conditions in BFF cache keys to avoid contamination from different permissions.
  • Errors are separated into user-facing messages, HTTP status, and internal log codes.

Observe how it breaks

In testing, we separate integration tests per loader unit and unit tests for Hono API. For BFF, we check how the screen is displayed when some of multiple APIs fail, and for Hono, we confirm whether permission violations and invalid inputs are correctly returned.

In testing, we separate BFF integration tests and Hono API contract tests. Since a correct API alone does not guarantee a correct screen, we verify partial API failures, insufficient permissions, empty data, and loader behavior during delays as separate cases.

Discarded options and trade-offs

Making the BFF thick makes screen development easier, but it becomes harder to use from other screens or external integrations. Making it too thin leaks business knowledge to the frontend. The criterion for judgment is whether the processing is for screen display convenience or a business rule.

Making the BFF thick speeds up screen-unit development, but makes it harder to reuse the same logic from other screens. Making it too thin leaks business decisions to the frontend. Separating update rules and read aggregation becomes the criterion for determining thickness.

Decision axes to retain in practice

In the combination of React Router and Hono, it's important not to be complacent about being able to write in the same language, but to explicitly define boundaries. A stable division of roles is for the BFF to absorb screen complexity and for business APIs to be maintained as long-lasting contracts.

The strength of React Router and Hono is not in eliminating boundaries, but in making boundaries visible through types. When you distinguish which types are for the screen and which types are for API contracts, the benefits of TypeScript directly translate into maintainability.

Technical documents

We will continue to increase technical documentation.

We will continue to organize our thoughts on AI, cloud, business app development, requirements definition, and operational design into documents.

Go to technical documentation list