authClient.listSessions returns empty array

Hey everyone, I'm trying to list the sessions of the user to display in their profile, but authClient.listSessions always returns an empty string. What am I missing? backend (hono js):
export const auth = betterAuth({
emailAndPassword: {
enabled: true,
},
database: drizzleAdapter(db, {
provider: 'pg',
schema: {
session: sessionTable,
user: userTable,
account: accountTable,
verification: verificationTable,
},
}),
trustedOrigins: [env.BASE_URL],
plugins: [openAPI()],
});
export const auth = betterAuth({
emailAndPassword: {
enabled: true,
},
database: drizzleAdapter(db, {
provider: 'pg',
schema: {
session: sessionTable,
user: userTable,
account: accountTable,
verification: verificationTable,
},
}),
trustedOrigins: [env.BASE_URL],
plugins: [openAPI()],
});
frontend (react)
import { createAuthClient } from 'better-auth/react';

export const authClient = createAuthClient({
baseURL: import.meta.env.VITE_API_BASE_URL,
});

const result = await authClient.listSessions();
import { createAuthClient } from 'better-auth/react';

export const authClient = createAuthClient({
baseURL: import.meta.env.VITE_API_BASE_URL,
});

const result = await authClient.listSessions();
Everything else seems to work fine, the sessions are persisted in pg. (same question on Reddit: https://www.reddit.com/r/better_auth/comments/1jguvvs/authclientlistsessions_returns_empty_array/)
Solution:
@bekacru I forgot to post it here, but it has been solved, user error 🙂 https://github.com/better-auth/better-auth/issues/1965...
GitHub
authClient.listSessions returns empty array · Issue #1965 · bette...
Is this suited for github? Yes, this is suited for github To Reproduce Project Stack: hono better-auth postgres When calling either authClient.listSessions or auth.api.listSessions it always return...
Jump to solution
2 Replies
bekacru
bekacru•4w ago
update to latest if you're not in 1.2.5
Solution
jovanazugy
jovanazugy•4w ago
@bekacru I forgot to post it here, but it has been solved, user error 🙂 https://github.com/better-auth/better-auth/issues/1965
GitHub
authClient.listSessions returns empty array · Issue #1965 · bette...
Is this suited for github? Yes, this is suited for github To Reproduce Project Stack: hono better-auth postgres When calling either authClient.listSessions or auth.api.listSessions it always return...

Did you find this page helpful?