TanStackT
TanStack3mo ago
2 replies
primary-violet

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?
Was this page helpful?