Kevin
Explore posts from serversBABetter Auth
•Created by Kevin on 4/30/2025 in #help
Help Understanding Better-auth
Thanks for your help. My question was basically trying to understand how they should be used together and really if there state is in sync. When a project gets massive and im using many plugins with different api's, i want to avoid out of sync UI
15 replies
BABetter Auth
•Created by Kevin on 4/30/2025 in #help
Help Understanding Better-auth
Thats the thing though it does revalidate using the auth.api without any revalidation logic or caching. Im assuming this is because of next headers which is dynamic and can only be dynamic. Im assuming theres some type of revalidation happening because of headers but im not sure
15 replies
BABetter Auth
•Created by Kevin on 4/30/2025 in #help
Help Understanding Better-auth
To make it clearer all my data fetching is done in server components which means there is no way to pass the active org id from the client to server, so i need to use auth.api to get the active org id. now lets say im on a jobs page which has the jobs displayed using the active org id. If i have my org switcher in the sidebar and use the authClient to switch orgs, client components that use authClient to get active org will be reactive to the change but the jobs wont be reactive as they use auth.api to get the org id so youll have a new active org with jobs from the previous active org. The is easily fixed by using a server action instead to change org. But this situation is why im asking if they should be used together
15 replies
BABetter Auth
•Created by Kevin on 4/30/2025 in #help
Help Understanding Better-auth
When i say interchangeably i mean fetching in server components using auth.api and setting in client components using authClient
"As far as I am concerned you should use auth.api on the server, and authClient on the client (as the names suggest)."
This is obvious and gives the impression to use interchangeably as needed. The problem im seeing though is fetching with auth.api and setting with authClient causes UI to be out of sync which is a problem. If i set with auth.api inside of a server action then this does revalidate the auth.api fetch somehow, if through headers changing im not sure.
This comes back to my question, are they meant to be used interchangeably
15 replies