Skip to content

getConnInfo

reference
1 min readUpdated

Kind: Function

Source: src/adapter/bun/conninfo.ts

Part of: Adapter

Get ConnInfo with Bun

getConnInfo reads connection details for the current request when running on Bun. It is intended for handlers that need access to request connection metadata through the Bun adapter.

Signature

ts
function getConnInfo(c: Context)

Parameters

NameType
cContext

Diagram

mermaid
graph LR
  Request --> Context
  Context --> getConnInfo
  getConnInfo --> BunServer
  BunServer --> ConnInfo
  ConnInfo --> Handler

Usage

ts
import { Hono } from 'hono'
import { getConnInfo } from 'hono/bun'

const app = new Hono()

app.get('/connection', (c) => {
  const connInfo = getConnInfo(c)

  return c.json(connInfo)
})

export default app

AI Coding Instructions

  • Call getConnInfo from a request handler with the active Hono context.
  • Use this Bun-specific helper only when the application is running with the Bun adapter.
  • Keep connection metadata handling separate from request parsing and response creation.
  • Handle missing or unavailable connection details before relying on them for application logic.

Relationships

  • IMPORTS → getBunServer

Was this page helpful?

Download as PDF
getConnInfo — Hono (narrator proof)