Populate an organization switcher
Organization selection
Kinde · Function
Retrieves an array of every organization the authenticated user can access. In the React SDK, call it from useKindeAuth() and await the result.
Call this method from the Kinde React SDK to asynchronously retrieve every organization available to the authenticated user. The result is an array that can be used to display an organization list or build an organization switcher.
getUserOrganizations(): Promise<Organization[]>An array of all organizations the user has access to.
const { getUserOrganizations } = useKindeAuth();
async function showOrganizations() {
const organizations = await getUserOrganizations();
console.log(organizations);
}
showOrganizations();Calls the React SDK method and logs the organizations available to the authenticated user.
Organization selection
Access-aware navigation
Account context
It retrieves an array containing all organizations the user has access to. In the React SDK, obtain the method from useKindeAuth and await its result.
Follow-up: How could the result support organization switching? Use the returned organization choices to let the user select a target, then initiate authentication or application-specific switching with that organization's code.
The React documentation shows it being called without arguments: getUserOrganizations(). The call is asynchronous, so its result should be awaited before it is consumed.
Follow-up: What should the UI do while the promise is pending? Render a loading state, then handle the resolved organization list before enabling selection.
The method is useful when an application needs to present the organizations available to a user. The documentation's example logs the resolved value, while the returned list can also drive an organization selector.
Follow-up: What additional organization context may be needed after selection? Retrieve or use the selected organization's code when the surrounding SDK flow requires a specific organization.
getOrganizationuseKindeAuthgetUser