Here's how I get the authenticated user with type safety using Hono and BetterAuth.
Here's the middleware. Using c.set(), I save the user and session in the current request:
import { createMiddleware } from "hono/factory";
import { auth } from "#app/lib/auth";
export const loggedInRequired = createMiddleware<{
Variables: {