Infer type is empty in hono
In the auth.ts file , while following the hono better-auth docs. It states to infer the user and session type use
auth.$infer
.
But in my case that is an empty object. I am binding that to Hono app by const app = new Hono<{Binding: AuthType}>
which according to docs should set the type for users and session.
this is the type that i get back when using auth.api.getSession()
why is it unknown ?Solution:Jump to solution
hello
also check your config (like empty plugins array etc), had this kind of errors before too...
8 Replies

try this
then use
SessionType['user']
also I think you need to pass in the db for it to workI do not get it .. why does this also have the session and use type as
unknown
?

even if i use Awaited<Promise>. the session is unknown

Solution
hello
also check your config (like empty plugins array etc), had this kind of errors before too
That was the reason.
another question in hono , is how should we bind the authtypes ? in the hono website the example given is like this
but then i am getting error calling
c.get("user")
you need to pass it as variables
then in a middleware set the auth info with
c.set