Runtime Framework
Modern.js uses Hono.js as the BFF and Server runtime framework, so you can extend BFF Server based on the Hono.js ecosystem.
Getting Request Context
Sometimes in BFF functions, it's necessary to obtain the request context to handle more logic. In such cases, you can use useHonoContext to get it:
For more details, refer to useHonoContext.
Getting Cookies
When getting cookies in BFF functions, you need to get the request context through useHonoContext, then use c.req.header('cookie') to get the Cookie string and parse it manually:
The c.req.cookie() method does not exist in the current version. You need to use c.req.header('cookie') to get the Cookie string and parse it manually.
Defining BFF Functions
When using Hono as the runtime framework, you can define interfaces through Api functions:
For more details about Api functions and operators, refer to Creating Extensible BFF Functions.
Using Middleware
Hono supports a rich middleware ecosystem, and you can use middleware in BFF functions:
For more details about middleware, refer to Creating Extensible BFF Functions.
More Hono Documentation
For more detailed information about Hono, please refer to the Hono official documentation.