Soheel
BABetter Auth
•Created by Kevin on 4/30/2025 in #help
Help Understanding Better-auth
In this case unless you use a context or some other state that tells the components to refetch on client side, yes using authClient is not suitable for that. Using interchangeably however for first populating on server, and then refetching on client is what I do mostly
15 replies
BABetter Auth
•Created by Kevin on 4/30/2025 in #help
Help Understanding Better-auth
If you were to update your clients company using a server action and the api object, your ui also wouldn't refresh unless you trigger a rerender of the page
15 replies
BABetter Auth
•Created by Kevin on 4/30/2025 in #help
Help Understanding Better-auth
You are free to use them how you like, one can be executed on the client, one on the server
15 replies
BABetter Auth
•Created by Kevin on 4/30/2025 in #help
Help Understanding Better-auth
I mean that is just a typical issue of getting data on inital load vs. refreshing it on the client
15 replies
BABetter Auth
•Created by deved9036 on 4/30/2025 in #help
useSession query behaviour?
Btw you can set this as "Solved" so people can more easily find it
18 replies
BABetter Auth
•Created by deved9036 on 4/30/2025 in #help
useSession query behaviour?
This library is lowkey really awesome, but sometimes you really need to dig through the docs at points you would not expect initially :D
18 replies
BABetter Auth
•Created by deved9036 on 4/30/2025 in #help
useSession query behaviour?
Love to hear it :D
18 replies
BABetter Auth
•Created by deved9036 on 4/30/2025 in #help
useSession query behaviour?
I use them myself, but didn't test whether useSession returns them, I didn't need them for that sake
18 replies
BABetter Auth
•Created by deved9036 on 4/30/2025 in #help
useSession query behaviour?
https://www.better-auth.com/docs/reference/options
Have you tried the additionalFields in the betterAuth config ?
18 replies
BABetter Auth
•Created by Kevin on 4/30/2025 in #help
Help Understanding Better-auth
As far as I am concerned you should use auth.api on the server, and authClient on the client (as the names suggest).
Most api functions provide a way to identify things you deal with. So If you have a more complex operation that should be kind of "atomic", you can define a server action that executes the functions usign the provided api instance by specifically identifying the subjects/objects you interact with (I havent used organization plugin myself but I assume there is a way to provide the identification using the body paramters)
When you are on the client and want to do simple operations arleady directly supported by the plugin, which are already "atomic", you can directly invoke the functions of the authClient on the client side, which then in turn sends a request to your API routes defined through better-auth.
So in short:
Server -> API
Client -> AuthClient
(At least this is how I understood it whilst using better-auth so far, but I may be mistaken)
https://www.better-auth.com/docs/concepts/api
https://www.better-auth.com/docs/concepts/client
15 replies
BABetter Auth
•Created by Soheel on 4/28/2025 in #help
Enabling OTP-Email 2FA Automatically on User Signup
I managed to work around it by creating the 2FA Entries in the DB by myself by copying the implementation from the better-auth Github. This however is not a pretty solution as it would break in case better-auth changes something on their end as I cannot access the functions needed from better-auth/crypto directly through imports. In case someone has a better idea I would love to hear it!
3 replies
BABetter Auth
•Created by Jïns on 4/26/2025 in #help
Unable to check permisions
Worth going through the Concepts pages
9 replies
BABetter Auth
•Created by Jïns on 4/26/2025 in #help
Unable to check permisions
@Jïns
You cannot use the authClient on the Server, the AuthClient basically calls your backend fromt he client side. If you are on the Server you need to get the Session and use the api.userHasPermission function:
9 replies