auth.api.getSession() returns unknown for user and session

Package: [email protected] I'm using better-auth with Drizzle ORM, and although the system works correctly at runtime, the types I get from auth.api.getSession() are not as expected. The inferred type is: const session: { session: unknown; user: unknown; } | null šŸ™ Could you confirm if this is expected? Or if there's a way to have the types automatically inferred from the adapter?
5 Replies
Ping
Ping•3w ago
Can I see your auth config?
BannedNull
BannedNullOP•3w ago
export const auth = betterAuth({
database: drizzleAdapter(db, {
provider: 'pg',
schema: user,
usePlural: true,
}),
socialProviders: {
github: {
clientId: env.GITHUB_CLIENT,
clientSecret: env.GITHUB_SECRET,
},
},
});
export const auth = betterAuth({
database: drizzleAdapter(db, {
provider: 'pg',
schema: user,
usePlural: true,
}),
socialProviders: {
github: {
clientId: env.GITHUB_CLIENT,
clientSecret: env.GITHUB_SECRET,
},
},
});
Ping
Ping•3w ago
Unrelated to your issue, but are you sure you setup the schema correctly? Normally we don't pass the user schema direct like that
Ping
Ping•3w ago
Just copied your auth config, and looks fine to me šŸ¤”
No description
BannedNull
BannedNullOP•3w ago
the server works fine. sorry it was my fault in the config I had plugins: []
export const auth = betterAuth({
...
plugins: [], //the error
});
export const auth = betterAuth({
...
plugins: [], //the error
});
can't be without plugins

Did you find this page helpful?