Client not inferring customerSession type

I am unable to get the client to get the type of the customSession object. Here is my backend code and my client code The permissions, teams, roles and user.accessLevel are not referred to on the client. I am using betterAuth 1.3.1
No description
No description
14 Replies
P1NKPR0
P1NKPR0OP4mo ago
This is how i am exporting Auth from the backend.
No description
P1NKPR0
P1NKPR0OP4mo ago
@Better Auth any input on this?
Better Auth
Better Auth4mo ago
Hey there! Could you clarify what you’re referring to? There have been several common topics lately—ranging from framework integrations (like Remix or Expo [1], [10]), to how custom additional fields work with the input property [2], or even suggestions for a debug mode [19]. Let me know which area you’d like to discuss, and I’ll be happy to dive in with more details! Sources: 1. Remix Integration | Better Auth 10. Expo Integration | Better Auth 2. TypeScript | Better Auth 19. is better-auth has debug mode like next-auth
GitHub
better-auth/better-auth
The most comprehensive authentication framework for TypeScript - better-auth/better-auth
Remix Integration | Better Auth
Integrate Better Auth with Remix.
P1NKPR0
P1NKPR0OP3mo ago
@Ping Can you please help me with this one
Ping
Ping3mo ago
@P1NKPR0 Are you working on a monorepo workspace?
P1NKPR0
P1NKPR0OP3mo ago
Yes i am
Ping
Ping3mo ago
@P1NKPR0 Can you help me test if you still run into the same issue if you were to create the authClient in the same file as the auth.ts and checked the type on useSession in that file too
kingitaj
kingitaj3mo ago
Having the same issue in a turbo monorepo. Creating the auth client in the same file does return the full session info for me. lol...I love coding. I found the issue. Being that we have a strict set to false for our backend (gradual js to ts migration) one of the custom methods we have in the sever better-auth instance had a type error and that seems to have been what was causing the issue. @P1NKPR0 if you are still having this issue check if you have type errors that are being surpressed.
P1NKPR0
P1NKPR0OP3mo ago
When i call getSession on the backend, it does include the custom session variables. but on the frontend, it's still not getting the types. @kingitaj to your point i made sure both have strict mode on and no other issues with better-auth The values are returned on the frontned but the types are not inferred
No description
P1NKPR0
P1NKPR0OP3mo ago
I found the issue but what could be causing it? if i specify "as string" for the env variables under socialProviders, customSessionClient infers the correct types on the frontend.
No description
P1NKPR0
P1NKPR0OP16h ago
@Ping any updates on this? @Max i am still having issue with this, can you please point me towards fixing it
P1NKPR0
P1NKPR0OP16h ago
i found an issue also with trustedOrigins, the type needs to be specified for it to work properly, if not, it will break.
trustedOrigins: allowedHosts as string[],
trustedOrigins: allowedHosts as string[],
even though, allowedHosts is already an array of string. but i needed to specify the type again. what could be causing this? it took me so long to get to the bottom of it
No description
Ping
Ping16h ago
Can you show me how you're exporting the Auth type?
P1NKPR0
P1NKPR0OP15h ago
Its based on Bun's monorepo. It looks like i fixed the issue with the strict type for trustedOrigins. I had the same issue with another project, which were the initial images uploaded. for that i fixed it by also strcit typing the env variables
No description
No description

Did you find this page helpful?