Skip to content

fix(nextjs): refresh the organization list after an organization is created - #559

Open
DonOmalVindula wants to merge 1 commit into
asgardeo:mainfrom
DonOmalVindula:fix/nextjs-revalidate-organizations
Open

fix(nextjs): refresh the organization list after an organization is created#559
DonOmalVindula wants to merge 1 commit into
asgardeo:mainfrom
DonOmalVindula:fix/nextjs-revalidate-organizations

Conversation

@DonOmalVindula

Copy link
Copy Markdown
Contributor

Problem

OrganizationProvider expects a revalidateMyOrganizations function, and <CreateOrganization /> calls it after a successful creation so the organization list reflects the new organization. The Next.js server provider never passed one (the client provider forwarded undefined as any), so the refresh was skipped and <OrganizationSwitcher /> kept showing the old list until the page was reloaded. The React SDK re-fetches the list.

Fix

  • AsgardeoServerProvider passes the existing getMyOrganizations server action as revalidateMyOrganizations.
  • AsgardeoClientProvider keeps myOrganizations in state (initialised from and synced with the server-provided list) and, when revalidation is requested, calls the action and stores the result so every consumer of the organization context sees the new list.

Testing

  • pnpm lint, tsc --noEmit and pnpm vitest run (60 tests) for @asgardeo/nextjs. There is no component test setup in this package, so the provider change is covered by review.

Changeset included (@asgardeo/nextjs patch).

🤖 Generated with Claude Code

…reated

AsgardeoProvider never passed a revalidateMyOrganizations function to the
organization context, so CreateOrganization skipped the refresh and the
switcher kept the old list until a reload.

The server provider now passes the getMyOrganizations action, and the client
provider keeps the list in state and updates it when the action resolves, as
the React SDK does.

Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
@coderabbitai

coderabbitai Bot commented Sep 6, 2026

Copy link
Copy Markdown

Warning

Review limit reached

Next included review available in 13 minutes.

Check out review usage here.

View limit details

Limit details: You’ve used the included review currently available.

You've used all free OSS reviews for now. Wait for the free limit to reset to keep reviewing this public repository.

Learn how review limits work.

Review configuration:

⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Team

Run ID: 56f0c1bb-1385-424b-82b1-0ec1ee2d7449

📥 Commits

Reviewing files that changed from the base of the PR and between 409ebae and 4df20f1.

📒 Files selected for processing (3)
  • .changeset/nextjs-revalidate-organizations.md
  • packages/nextjs/src/client/contexts/Asgardeo/AsgardeoProvider.tsx
  • packages/nextjs/src/server/AsgardeoProvider.tsx

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@asgardeo-github-bot

Copy link
Copy Markdown

🦋 Changeset detected

The changes in this PR will be included in the next version bump.

Not sure what this means? Click here to learn what changesets are.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants