Is it a possible to use a relation table as type for fields in additionalFields ? (beginner ๐ )
I'm currently working with better-auth and Iโd like to access the
pages
field of the user directly from the session (code snippet below). (It's another table).
Is it possible / a good idea to include this kind of data directly in the session (via customSession) or should I rather fetch it separately using a /me
endpoint after login?
Iโm not an auth expert, so Iโm not 100% sure what the best practice is here โ any feedback or guidance would be super appreciated! ๐
Hereโs what Iโve got so far ๐
TLDR ;
โ
Is it okay to include pages directly in the session?
๐ค Or is it better to keep the session lightweight and fetch /me
on the client side?
3 Replies
I dont think we support a type
array
for field type, but we do have string[]
as well as number[]
Oups, that was for testing purposes. I just missed the fact that i needed
customSessionClient
instead of inferAdditionalFields
Now everything is fully typed, even the relation with pages
What's your opinion about this ?
โ
Is it okay to include pages directly in the session
๐ค Or is it better to keep the session lightweight and fetch /me on the client sideDepends, I have no clue what the purpose of
pages
is, how large of an array it may be, etc etc.
If you think pages
is heavy, or could take a little bit to fetch, then maybe it's not worth it? not sure.