Incorrect Response Data

Hi there I have setup better auth to be snake case but when i use
const sess = await auth.api.listSessions({
headers: c.req.raw.headers
});
const sess = await auth.api.listSessions({
headers: c.req.raw.headers
});
but this is what returned to me
[
{
"expiresAt": "2025-05-25T04:19:35.528Z",
"token": "mytoken",
"createdAt": "2025-05-24T04:19:35.528Z",
"updatedAt": "2025-05-24T04:19:35.528Z",
"ipAddress": "",
"userAgent": "",
"userId": "myuserid",
"id": "myid"
}
]
[
{
"expiresAt": "2025-05-25T04:19:35.528Z",
"token": "mytoken",
"createdAt": "2025-05-24T04:19:35.528Z",
"updatedAt": "2025-05-24T04:19:35.528Z",
"ipAddress": "",
"userAgent": "",
"userId": "myuserid",
"id": "myid"
}
]
i expected the response to look like this
[
{
"expires_at": "2025-05-25T04:19:35.528Z",
"token": "mytoken",
"created_at": "2025-05-24T04:19:35.528Z",
"updated_at": "2025-05-24T04:19:35.528Z",
"ip_address": "",
"user_agent": "",
"user_id": "myuserid",
"id": "myid"
}
]
[
{
"expires_at": "2025-05-25T04:19:35.528Z",
"token": "mytoken",
"created_at": "2025-05-24T04:19:35.528Z",
"updated_at": "2025-05-24T04:19:35.528Z",
"ip_address": "",
"user_agent": "",
"user_id": "myuserid",
"id": "myid"
}
]
Solution:
There isn't a solution which will solve all cases of returned data, however the primary data you'll receive is likely from useSession / getSession, which fortunutely has a way to suit your needs. I recommend checking out the custom session plugin which you can return lowercase names as needed....
Session Management | Better Auth
Better Auth session management.
Jump to solution
4 Replies
Ping
Ping5mo ago
Hello, our internal adapter system translates the data accordingly. All plugins and internal code is built around consistent naming of these variables. If that data were to change because your database field names were different, all plugins and internal systems wouldn't work. Is there a specific reason you need it lowercase?
Faris
FarisOP5mo ago
Hi there thank you for clarifying. Currently when i want to login i need to get the user id from better auth and make a query to my database so my data returns as snake case which is consistent across my api
Solution
Ping
Ping5mo ago
There isn't a solution which will solve all cases of returned data, however the primary data you'll receive is likely from useSession / getSession, which fortunutely has a way to suit your needs. I recommend checking out the custom session plugin which you can return lowercase names as needed.
Session Management | Better Auth
Better Auth session management.
Faris
FarisOP5mo ago
yup just what i needed. thank you

Did you find this page helpful?