Skip to main content

useOrganizations()

useOrganizations() is a stateful hook providing access to information about organizations the user is a member of. Use this hook to list organizations, see the current organization and switch to another organization.

Each instance of this hook will fetch its own organization data, use with caution.

Usage

import { useOrganizations } from "@slashid/react";

function Component() {
const {
organizations,
currentOrganization,
switchOrganization,
isLoading
} = useOrganizations()

// ...
}

API

PropertyTypeDescription
currentOrganizationOrganizationDetails | nullThe users current organization, resolves to null during initialisation
organizationsOrganizationDetails[]A list of all organizations the user is a member of
switchOrganization({ oid: string }) => voidSwitches to another organization. A new SlashID user token is minted which is scoped to the new organization, it has the same factors and expiry as the previous token.
isLoadingbooleanThe loading state of the organization data provided by this hook