Is there a way to get the additionalFields in the useSession hook?
I dont know if this has been asked before (couldnt find anything in the search, but is it possinle that if i add an additional field (call it role, like in the example) that i can see it in the
useSession hook?6 Replies
yes add
inferAdditionalFields plugin to the authClient
this one is there in the type system, but not there in the runtime
if i add that code it works in the type system, but when i look for it in the runtime the
useSession hook does not return that value from the userthat's not correct, they exists in the runtime.
make sure you are on the latest version and did the database migration.
if it doesn't work consider opening an issue on github.
i got it working. it was the database migration all along :/ however i found a bug that i will raise an issue later today or tomrrow..
when using sqlite and adding additionalfields as boolean wirth a defaultValue of false, it was setting it to
true weirdly enoughcheck the migrations files and see if the filed is set to
DEFAULT FALSE or not if its not present please post on github issues.
consider marking this as done or solvedSession Management | Better Auth
Better Auth session management.