For AI agents: the complete documentation index is available at /zh/llms.txt, the full documentation bundle is available at /zh/llms-full.txt, and this page is available as Markdown at /zh/apis/app/runtime/bff/use-hono-context.md.
  • 简体中文
  • useHonoContext

    用于在一体化 BFF 函数中获取 Hono 上下文。

    使用姿势

    import { useHonoContext } from '@modern-js/server-runtime';

    函数签名

    function useHonoContext(): Context

    示例

    开发者可以通过 context 获取更多的请求信息,例如设置响应头:

    import { useHonoContext } from '@modern-js/server-runtime';
    
    export async function get() {
      const c = useHonoContext();
      c.res.headers.set('x-bff-api', 'true');
      // ...
    }