BA
Better Auth•3mo ago
NunoLima

how to correctly type useSession on the client side

I'm using React and using the useSession hook that comes from authClient, the data type comes as const data: { user: any; session: any; } | null. I saw the correct values in the console. How can I correctly type the user and session? This is my first time doing this setup
No description
No description
8 Replies
Ping
Ping•3mo ago
That's certainly unusual. Just a few questions: Are you in a monorepo setup? What's the import path for createAuthClient in your case in your auth config? Can I see your tsconfig?
NunoLima
NunoLimaOP•3mo ago
Mono repo with multiple clients, without api but we intend to move the api to mono repo as well. At the moment only in the clintes
NunoLima
NunoLimaOP•3mo ago
No description
NunoLima
NunoLimaOP•3mo ago
No description
NunoLima
NunoLimaOP•3mo ago
No description
Ping
Ping•3mo ago
In the same file which you defined the authClient, can you see if the types are correct for authClient.useSession?
NunoLima
NunoLimaOP•3mo ago
No description
Ping
Ping•3mo ago
It could be related to the tsconfig but I'm not too sure, I can't spot anything that I know would cause common BetterAuth related issues. Using the most basic form of setup like you have should work, I think the issue stems somewhere between the monorepo and tsconfig 🤔

Did you find this page helpful?