logo
  • Guide
  • Config
  • Plugin
  • API
  • Examples
  • Community
  • Modern.js 2.x Docs
  • English
    • 简体中文
    • English
    • Commands
      File Conventions
      src/
      App.tsx
      entry.ts
      entry.server.tsx
      modern.runtime.ts
      routes/
      *.[server|node].tsx
      api/
      lambda/*.ts
      server/
      modern.server.ts
      shared/
      config/
      html/
      favicon.*
      icon.*
      mock/
      public/
      upload/
      modern.config.ts
      Runtime
      Core
      createRoot
      render
      RuntimeContext
      Router
      router
      SSR
      NoSSR
      renderStreaming
      renderString
      createRequestHandler
      BFF
      useHonoContext
      Utility
      CSS-In-JS API
      Head
      loadable
      📝 Edit this page
      Previous pagecreateRequestHandlerNext pageCSS-In-JS API

      #useHonoContext

      Used to obtain Hono context in an integrated BFF function.

      #Usage

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

      #Function Signature

      function useHonoContext(): Context

      #Example

      Developers can use context to obtain more request information, such as setting response headers:

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