13 Replies
Try passing
headers
to your listUsers function parameters
Object literal may only specify known properties, and 'headers' does not exist in type 'Prettify<{ query: { limit?: string | number | undefined; offset?: string | number | undefined; sortBy?: string | undefined; searchValue?: string | undefined; searchField?: "email" | "name" | undefined; ... 4 more ...; filterOperator?: "eq" | ... 5 more ... | undefined; }; fetchOptions?: { ...; } | undefined; }>'
Sorry, I mean in fetchOptions, then headers:
Is it in the new version? Because the documentation doesn't say anything about it

It's a general rule of thumb across better-auth.
Mostly only used on server auth API methods since the server doesn't know which user the api call is for, but there are cases occasionally on the client where it doesn't know how to pass the headers by itself when using the auth-client.
Since the headers contains your cookies, which contains the user info.
But yeah, you'll noticed every auth client method looks pretty much the same with the parameters.
Sometimes it will require
body
, other times query
(depends on the endpoint, whether it's POST or GET), but it will always contain the fetchOptions
.the video does not transmit headers and everything works fine, is this because of this 'use client' ?

It's very possible.
If your component isn't erroring, and you don't have "use client", then it's probably a RSC. Meaning it's being ran on the server - this would explain why it didn't know how to get the user's headers.
one small question
how do I expand type in db i have field organization: text("organization"),

I assume you already added the additional fields on the server better-auth instance.
Have you added the
inferAdditionalFields
plugin on your client better-auth instance?
https://www.better-auth.com/docs/concepts/typescript#inferring-additional-fields-on-clientTypeScript | Better Auth
Better Auth TypeScript integration.
for export type User = typeof auth.$Infer.Session.user it worked
There's a different type here and it didn't work

Didn't work as in it errored in run-time? or as in you saw a typescript error?


inferAdditionalFields will only work on any methods that is defaultly provided by the auth-client.
So all other plugins can't infer those new types, including the admin plugin.
Meaning that it's possible that the values you typed are valid, it's just typescript doesn't know that...