Skip to content

getConnInfo

reference
1 min readUpdated

Kind: Function

Source: src/adapter/deno/conninfo.ts

Part of: Adapter

Get conninfo with Deno

getConnInfo reads connection details from the Deno request environment for a Hono context. It returns the remote and local address information associated with the current request, allowing handlers to inspect client and server connection data.

Signature

ts
function getConnInfo(c)

Parameters

NameType
cany

Diagram

mermaid
graph LR
  Request[Deno request] --> Context[Hono context]
  Context --> Environment[Deno connection environment]
  Environment --> getConnInfo[getConnInfo]
  getConnInfo --> ConnInfo[Remote and local connection info]

Usage

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

const app = new Hono()

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

  return c.json({
    remote: connInfo.remote,
    local: connInfo.local,
  })
})

Deno.serve(app.fetch)

AI Coding Instructions

  • Call getConnInfo with the current Hono Context inside a request handler.
  • Treat connection addresses as request metadata and account for missing address fields where deployment environments do not expose them.
  • Keep Deno-specific connection handling within the Deno adapter rather than reading adapter environment values directly in shared application code.
  • Import the connection helper from hono/conninfo so the matching runtime implementation is selected.

Was this page helpful?

Download as PDF
getConnInfo — Hono (narrator proof)