Import
Type Definitions
The ConnInfo helper exports TypeScript types for working with connection information:ConnInfo
The main connection information interface:NetAddrInfo
Network address information for a connection:AddressType
The type of network address:GetConnInfo
Helper type for functions that extract connection info from context:Usage with Adapters
Connection information extraction is adapter-specific. Many runtime adapters provide agetConnInfo function:
Cloudflare Workers
Deno
Bun
Node.js
Common Use Cases
IP Address Logging
Log client IP addresses for requests:IP-based Rate Limiting
Implement simple IP-based rate limiting:Geolocation-based Content
Serve different content based on IP address:Security Checks
Implement IP allowlisting or blocklisting:Debug Information
Return connection details for debugging:IPv4 vs IPv6
Check the address type to handle IPv4 and IPv6 differently:Adapter Availability
Connection info support varies by runtime adapter:Cloudflare Workers
Full support via
hono/cloudflare-workersDeno
Full support via
hono/denoBun
Full support via
hono/bunNode.js
Available via
@hono/node-server/conninfoCheck your specific adapter’s documentation for
getConnInfo availability and implementation details.Behind Proxies
When your application is behind a proxy or load balancer, the remote address will be the proxy’s IP. Use headers likeX-Forwarded-For for the actual client IP:
Best Practices
Check Adapter Support
Verify your runtime adapter supports
getConnInfo before usingHandle Undefined
Always handle cases where address or port may be undefined
Proxy Awareness
Use appropriate headers when behind proxies or load balancers
Privacy Compliance
Be mindful of privacy laws when logging or storing IP addresses