Next.js 15 + BetterAuth + HonoJS TS issues for user, session

Hello amigos,

I have strange issue.. So thats my simple API endpoint to get user profile:

.get(
"/profile",
async (c) => {
const session = c.get("session")
const user = c.get("user")

if(!user) return c.body(null, 401);


}
)

And the problem..
const session = c.get("session")
const user = c.get("user")

has TS errors.. i tried almost everything from:
Like set vars on hono init:

const app = new Hono<{
Variables: {
user: typeof auth.$Infer.Session.user | null;
session: typeof auth.$Infer.Session.session | null
}
}>({}).basePath("/api");

Using better auth default middleware:

app.use("*", async (c, next) => {
const session = await auth.api.getSession({ headers: c.req.raw.headers });

if (!session) {
c.set("user", null);
c.set("session", null);
return next();
}

c.set("user", session.user);
c.set("session", session.session);
return next();
});

But still.. cant see what is USER and SESSION and get ts errors.. i just cant understand why? What i miss?

Full errors:

<html>TS2769: No overload matches this call.<br/>Overload 1 of 2, '(key: never): unknown', gave the following error.<br/>Argument of type '&quot;user&quot;' is not assignable to parameter of type 'never'.<br/>Overload 2 of 2, '(key: never): never', gave the following error.<br/>Argument of type '&quot;user&quot;' is not assignable to parameter of type 'never'.

TS2339: Property 'id' does not exist on type '{}'.
Web framework built on Web Standards for Cloudflare Workers, Fastly Compute, Deno, Bun, Vercel, Node.js, and others. Fast, but not only fast.
Integrate Better Auth with Hono.
Was this page helpful?