Lambda Adapter #196

Closed
opened 2026-03-13 07:37:09 -05:00 by GiteaMirror · 1 comment
Owner

Originally created by @pgvr on GitHub (Nov 8, 2024).

Hi! I'd love an adapter for Lambda, as it's difficult to map the event type Lambda provides to the normal Request type of the default auth handler.
I would assume that APIGatewayProxyEventV2 and APIGatewayProxyEvent are the most common event types, but there could be more.
Hono is doing some mapping from events and results of Lambda here: https://github.com/honojs/hono/blob/main/src/adapter/aws-lambda/handler.ts

Originally created by @pgvr on GitHub (Nov 8, 2024). Hi! I'd love an adapter for Lambda, as it's difficult to map the `event` type Lambda provides to the normal `Request` type of the default auth handler. I would assume that `APIGatewayProxyEventV2` and `APIGatewayProxyEvent` are the most common event types, but there could be more. Hono is doing some mapping from events and results of Lambda here: https://github.com/honojs/hono/blob/main/src/adapter/aws-lambda/handler.ts
Author
Owner

@pgvr commented on GitHub (Nov 8, 2024):

I found a way to make this work for now like this. I installed Hono just for this so a better-auth "native" way could still be worth thinking about.

import { auth } from "@repo/auth"
import { Hono } from "hono"
import { handle } from "hono/aws-lambda"

const app = new Hono()

app.on(["POST", "GET"], "/*", (c) => {
	return auth.handler(c.req.raw)
})

export const handler = handle(app)
@pgvr commented on GitHub (Nov 8, 2024): I found a way to make this work for now like this. I installed Hono just for this so a better-auth "native" way could still be worth thinking about. ```ts import { auth } from "@repo/auth" import { Hono } from "hono" import { handle } from "hono/aws-lambda" const app = new Hono() app.on(["POST", "GET"], "/*", (c) => { return auth.handler(c.req.raw) }) export const handler = handle(app) ```
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: github-starred/better-auth#196