Skip to content

feat(adapter): add getConnInfo for AWS Lambda, Cloudflare Pages, and Netlify#4649

Merged
yusukebe merged 3 commits intohonojs:nextfrom
rokasta12:feat/conninfo-implementations
Feb 19, 2026
Merged

feat(adapter): add getConnInfo for AWS Lambda, Cloudflare Pages, and Netlify#4649
yusukebe merged 3 commits intohonojs:nextfrom
rokasta12:feat/conninfo-implementations

Conversation

@rokasta12
Copy link
Copy Markdown
Contributor

Summary

This PR adds getConnInfo() support to three adapters that were previously missing this functionality:

  • AWS Lambda - Supports API Gateway v1, v2, and ALB
  • Cloudflare Pages - Uses cf-connecting-ip header (same as Workers)
  • Netlify - Uses context.ip + bonus getGeo() helper

Changes

AWS Lambda (hono/aws-lambda)

  • Extracts client IP from requestContext.identity.sourceIp (API Gateway v1)
  • Extracts client IP from requestContext.http.sourceIp (API Gateway v2 / Function URLs)
  • Falls back to x-forwarded-for header (ALB)

Cloudflare Pages (hono/cloudflare-pages)

  • Uses cf-connecting-ip header (identical to Cloudflare Workers)

Netlify (hono/netlify)

  • Uses context.ip for client IP
  • Adds getGeo() helper for geolocation data (city, country, subdivision, timezone, postalCode, etc.)

Usage Examples

// AWS Lambda
import { Hono } from 'hono'
import { handle, getConnInfo } from 'hono/aws-lambda'

const app = new Hono()
app.get('/', (c) => {
  const info = getConnInfo(c)
  return c.text(`Your IP: ${info.remote.address}`)
})
export const handler = handle(app)

// Cloudflare Pages
import { handle, getConnInfo } from 'hono/cloudflare-pages'
// ... same pattern

// Netlify (with geo)
import { handle, getConnInfo, getGeo } from 'hono/netlify'
app.get('/', (c) => {
  const info = getConnInfo(c)
  const geo = getGeo(c)
  return c.json({ ip: info.remote.address, country: geo?.country?.code })
})

References

Checklist

  • Tests added (12 tests, 100% coverage on new files)
  • Follows existing patterns (matches cloudflare-workers, vercel, lambda-edge, etc.)
  • TypeScript types included
  • JSDoc with examples

@codecov
Copy link
Copy Markdown

codecov Bot commented Jan 26, 2026

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 91.46%. Comparing base (bcc81b1) to head (81ef5d1).
⚠️ Report is 30 commits behind head on next.

Additional details and impacted files
@@            Coverage Diff             @@
##             next    #4649      +/-   ##
==========================================
+ Coverage   91.45%   91.46%   +0.01%     
==========================================
  Files         173      176       +3     
  Lines       11322    11449     +127     
  Branches     3279     3322      +43     
==========================================
+ Hits        10354    10472     +118     
- Misses        967      976       +9     
  Partials        1        1              

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@yusukebe yusukebe added the v4.12 label Feb 2, 2026
Comment thread src/adapter/netlify/conninfo.ts Outdated
Copy link
Copy Markdown
Member

@yusukebe yusukebe left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM!

@yusukebe
Copy link
Copy Markdown
Member

Hi @rokasta12

I removed getGeo() from the Netlify adapter. The bonus is not needed! But, looks good. I'll merge this and include into the next minor version soon. Thanks!

@yusukebe yusukebe changed the base branch from main to next February 19, 2026 10:15
@yusukebe yusukebe merged commit 16321af into honojs:next Feb 19, 2026
21 checks passed
@rokasta12 rokasta12 mentioned this pull request May 3, 2026
4 tasks
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants