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
});


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"
    }
]


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"
    }
]
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.
Better Auth session management.
Was this page helpful?