Help Understanding Better-auth
Using Nextjs
Ive just started messing around with better auth to understand the fundamentals of how it works.
My question is around if auth and authClient are designed to be used interchangeably.
I'm testing out organizations and as expected using authClient hooks like useActiveOrganization() react to changes from the auth client like authClient.organization.setActive().
When using auth like auth.api.getFullOrganization() in server components this only revalidates when using auth.api.setActiveOrganization() and im assuming this happens due to headers being passed in, i could be wrong but it is somehow being revalidated/rerun.
The problem i see is if they are used interchangeably like fetching data based off the active org which uses auth.api, and i set a new active org using authClient.organization.setActive() this will cause components using authClient.useActiveOrganization() to react but the data that was fetched using auth.api would still be returning data from the old organization.
The only workaround i see is using one or the other consistently but since i do all my data fetching in server components id have to use auth.
Maybe i have this completely wrong but would be much appreciated if someone could give me insight on this? Thanks
Ive just started messing around with better auth to understand the fundamentals of how it works.
My question is around if auth and authClient are designed to be used interchangeably.
I'm testing out organizations and as expected using authClient hooks like useActiveOrganization() react to changes from the auth client like authClient.organization.setActive().
When using auth like auth.api.getFullOrganization() in server components this only revalidates when using auth.api.setActiveOrganization() and im assuming this happens due to headers being passed in, i could be wrong but it is somehow being revalidated/rerun.
The problem i see is if they are used interchangeably like fetching data based off the active org which uses auth.api, and i set a new active org using authClient.organization.setActive() this will cause components using authClient.useActiveOrganization() to react but the data that was fetched using auth.api would still be returning data from the old organization.
The only workaround i see is using one or the other consistently but since i do all my data fetching in server components id have to use auth.
Maybe i have this completely wrong but would be much appreciated if someone could give me insight on this? Thanks