[GH-ISSUE #7981] useActiveMember does not refetch when active organization changes #28283

Closed
opened 2026-04-17 19:43:24 -05:00 by GiteaMirror · 2 comments
Owner

Originally created by @itamarzwi on GitHub (Feb 15, 2026).
Original GitHub issue: https://github.com/better-auth/better-auth/issues/7981

Originally assigned to: @bytaesu on GitHub.

Is this suited for github?

  • Yes, this is suited for github

To Reproduce

  1. Create a backend & frontend with the organization plugin
  2. Have the user be part of 2 organizations and implement some sort of organization switching mechanism
  3. Call both authClient.useActiveOrganization() and authClient.useActiveMember() in the same component
  4. Set active organization and refresh from the useActiveOrganization hook
  5. The result returned from useActiveMember is stale

Current vs. Expected behavior

While this aligns with useActiveMember exporting its own refresh function, it is unintuitive that the result of useActiveMember will remain stale after refreshing the result of useActiveOrganization.

If not linking the refetching of these data states, perhaps a warning in the docs is in order?
Also, there is no mention of useActiveMember and useActiveMemberRole in the docs

What version of Better Auth are you using?

1.4.18

System info

Unsure what to put here since the output of `npx auth info --json` `is error: unknown command 'info' (Did you mean init?)`

Which area(s) are affected? (Select all that apply)

Client, Documentation

Auth config (if applicable)

import { betterAuth } from "better-auth"
import { organization } from "better-auth/plugins";

export const auth = betterAuth({
  plugins: [
    organization(),
  ],
});

// client
import {  organizationClient } from 'better-auth/client/plugins';
import { createAuthClient } from 'better-auth/react';

export const authClient = createAuthClient({
  plugins: [
    organizationClient(),
  ],
});

Additional context

No response

Originally created by @itamarzwi on GitHub (Feb 15, 2026). Original GitHub issue: https://github.com/better-auth/better-auth/issues/7981 Originally assigned to: @bytaesu on GitHub. ### Is this suited for github? - [x] Yes, this is suited for github ### To Reproduce 1. Create a backend & frontend with the organization plugin 2. Have the user be part of 2 organizations and implement some sort of organization switching mechanism 3. Call both `authClient.useActiveOrganization()` and `authClient.useActiveMember()` in the same component 4. Set active organization and refresh from the `useActiveOrganization` hook 5. The result returned from `useActiveMember` is stale ### Current vs. Expected behavior While this aligns with `useActiveMember` exporting its own refresh function, it is unintuitive that the result of `useActiveMember` will remain stale after refreshing the result of `useActiveOrganization`. If not linking the refetching of these data states, perhaps a warning in the docs is in order? Also, there is no mention of `useActiveMember` and `useActiveMemberRole` in the docs ### What version of Better Auth are you using? 1.4.18 ### System info ```bash Unsure what to put here since the output of `npx auth info --json` `is error: unknown command 'info' (Did you mean init?)` ``` ### Which area(s) are affected? (Select all that apply) Client, Documentation ### Auth config (if applicable) ```typescript import { betterAuth } from "better-auth" import { organization } from "better-auth/plugins"; export const auth = betterAuth({ plugins: [ organization(), ], }); // client import { organizationClient } from 'better-auth/client/plugins'; import { createAuthClient } from 'better-auth/react'; export const authClient = createAuthClient({ plugins: [ organizationClient(), ], }); ``` ### Additional context _No response_
GiteaMirror added the locked label 2026-04-17 19:43:24 -05:00
Author
Owner

@dosubot[bot] commented on GitHub (Feb 15, 2026):

Hi @itamarzwi! I'm Dosu and I’m helping the better-auth team.

You've identified a known limitation in Better Auth's organization plugin. The issue is that when setActive is called, it only triggers $sessionSignal, not $activeMemberSignal. The activeMember atom only listens to $activeMemberSignal, so it doesn't automatically refetch when the organization changes.

This is part of a broader architectural limitation discussed in issue #3837 where organization-related hooks don't automatically update when the active organization changes.

Workaround: Manually call refetch() after switching organizations:

const { data: activeMember, refetch: refetchMember } = authClient.useActiveMember();

await authClient.organization.setActive({ organizationId: orgId });
refetchMember(); // Manually refetch to get updated member data

You're also correct that useActiveMember and useActiveMemberRole are not documented—the hooks exist in the codebase but lack official documentation.

To reply, just mention @dosu.


How did I do? Good | Irrelevant | Incorrect | Verbose | Hallucination | Report 🐛 | Other

Chat with Dosu Open in Cursor Join Discord Share on X

<!-- gh-comment-id:3904728241 --> @dosubot[bot] commented on GitHub (Feb 15, 2026): <!-- Greeting --> Hi @itamarzwi! I'm [Dosu](https://go.dosu.dev/dosubot) and I’m helping the better-auth team. <!-- Answer --> You've identified a known limitation in Better Auth's organization plugin. The issue is that when [`setActive`](https://github.com/better-auth/better-auth/blob/0669ed804d8e0ada004c5ba266a6a12be6557cfc/packages/better-auth/src/plugins/organization/client.ts#L259-L264) is called, it only triggers `$sessionSignal`, not `$activeMemberSignal`. The [`activeMember` atom only listens to `$activeMemberSignal`](https://github.com/better-auth/better-auth/blob/0669ed804d8e0ada004c5ba266a6a12be6557cfc/packages/better-auth/src/plugins/organization/client.ts#L209-L216), so it doesn't automatically refetch when the organization changes. This is part of a [broader architectural limitation discussed in issue #3837](https://github.com/better-auth/better-auth/issues/3837#issuecomment-3161455738) where organization-related hooks don't automatically update when the active organization changes. **Workaround:** Manually call `refetch()` after switching organizations: ```javascript const { data: activeMember, refetch: refetchMember } = authClient.useActiveMember(); await authClient.organization.setActive({ organizationId: orgId }); refetchMember(); // Manually refetch to get updated member data ``` You're also correct that `useActiveMember` and `useActiveMemberRole` are not documented—the hooks exist in the codebase but lack official documentation. <!-- Dosu Comment Footer --> *To reply, just mention [@dosu](https://go.dosu.dev/dosubot).* --- <sup>How did I do? [Good](https://app.dosu.dev/response-feedback/ab651377-e5bb-4e32-a14f-0034305fb8fc?feedback_type=great_response) | [Irrelevant](https://app.dosu.dev/response-feedback/ab651377-e5bb-4e32-a14f-0034305fb8fc?feedback_type=irrelevant_answer) | [Incorrect](https://app.dosu.dev/response-feedback/ab651377-e5bb-4e32-a14f-0034305fb8fc?feedback_type=incorrect_sources) | [Verbose](https://app.dosu.dev/response-feedback/ab651377-e5bb-4e32-a14f-0034305fb8fc?feedback_type=too_verbose) | [Hallucination](https://app.dosu.dev/response-feedback/ab651377-e5bb-4e32-a14f-0034305fb8fc?feedback_type=hallucination) | [Report 🐛](https://app.dosu.dev/response-feedback/ab651377-e5bb-4e32-a14f-0034305fb8fc?feedback_type=bug_report) | [Other](https://app.dosu.dev/response-feedback/ab651377-e5bb-4e32-a14f-0034305fb8fc?feedback_type=other)</sup> [![Chat with Dosu](https://dosu.dev/dosu-chat-badge.svg)](https://app.dosu.dev/cdda13d9-dd27-4d31-b09a-5d8bec92de21/ask?utm_source=github)&nbsp;[![Open in Cursor](https://dosu.dev/dosu-in-cursor.svg)](https://cursor.com/link/prompt?text=You%27ve%20identified%20a%20known%20limitation%20in%20Better%20Auth%27s%20organization%20plugin.%20The%20issue%20is%20that%20when%20%5B%60setActive%60%5D%28https%3A//github.com/better-auth/better-auth/blob/0669ed804d8e0ada004c5ba266a6a12be6557cfc/packages/better-auth/src/plugins/organization/client.ts%23L259-L264%29%20is%20called%2C%20it%20only%20triggers%20%60%24sessionSignal%60%2C%20not%20%60%24activeMemberSignal%60.%20The%20%5B%60activeMember%60%20atom%20only%20listens%20to%20%60%24activeMemberSignal%60%5D%28https%3A//github.com/better-auth/better-auth/blob/0669ed804d8e0ada004c5ba266a6a12be6557cfc/packages/better-auth/src/plugins/organization/client.ts%23L209-L216%29%2C%20so%20it%20doesn%27t%20automatically%20refetch%20when%20the%20organization%20changes.%0A%0AThis%20is%20part%20of%20a%20%5Bbroader%20architectural%20limitation%20discussed%20in%20issue%20%233837%5D%28https%3A//github.com/better-auth/better-auth/issues/3837%23issuecomment-3161455738%29%20where%20organization-related%20hooks%20don%27t%20automatically%20update%20when%20the%20active%20organization%20changes.%0A%0A%2A%2AWorkaround%3A%2A%2A%20Manually%20call%20%60refetch%28%29%60%20after%20switching%20organizations%3A%0A%0A%60%60%60javascript%0Aconst%20%7B%20data%3A%20activeMember%2C%20refetch%3A%20refetchMember%20%7D%20%3D%20authClient.useActiveMember%28%29%3B%0A%0Aawait%20authClient.organization.setActive%28%7B%20organizationId%3A%20orgId%20%7D%29%3B%0ArefetchMember%28%29%3B%20//%20Manually%20refetch%20to%20get%20updated%20member%20data%0A%60%60%60%0A%0AYou%27re%20also%20correct%20that%20%60useActiveMember%60%20and%20%60useActiveMemberRole%60%20are%20not%20documented%E2%80%94the%20hooks%20exist%20in%20the%20codebase%20but%20lack%20official%20documentation.)&nbsp;[![Join Discord](https://img.shields.io/badge/join-5865F2?logo=discord&logoColor=white&label=)](https://go.dosu.dev/discord-bot)&nbsp;[![Share on X](https://img.shields.io/badge/X-share-black)](https://twitter.com/intent/tweet?text=%40dosu_ai%20helped%20me%20solve%20this%20issue!&url=https%3A//github.com/better-auth/better-auth/issues/7981)
Author
Owner

@bytaesu commented on GitHub (Feb 15, 2026):

Hi @itamarzwi,

Thanks for letting us know!
I'll check 🧐

<!-- gh-comment-id:3905306455 --> @bytaesu commented on GitHub (Feb 15, 2026): Hi @itamarzwi, Thanks for letting us know! I'll check 🧐
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: github-starred/better-auth#28283