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:

api/lambda/hello.ts
import { useHonoContext } from '@modern-js/plugin-bff/hono'
export const get = async () => {
  const c = useHonoContext();
  console.info(`access url: ${c.req.url}`);
  return 'Hello Modern.js'
};
INFO

For more details, refer to useHonoContext.