Using TanStack DB with Better Auth
Hey everyone,
I’m having some trouble understanding how TanStack DB should work together with Better Auth (Organizations).
Better Auth already provides built-in methods and hooks like setActiveOrganization, getFullOrganization, and others.
When using TanStack DB + ElectricSQL, does this mean I should always update organization data through TanStack DB instead of calling Better Auth directly?
For example — instead of doing something like:
await auth.api.organization.setActiveOrg(orgId)
should I be updating the "active organization" via a TanStack DB query instead?
Or can I just define the collection in TanStack DB, use live queries to reflect data changes, and still call Better Auth methods normally to handle auth-related actions?
2 Replies
ratty-blush•2w ago
Im not sure it matters much?
stormy-gold•2w ago
setActiveOrganization is something you want to do directly from authClient since it needs to update your cookie