useActiveOrganization
The useActiveOrganization hook provides access to the currently active organization and methods to manage it.
Return Value
The active organization object
activeMembership
OrganizationMembership | null
User’s membership in active organization
Show Refetch the active organization
Resolves when the active organization is refetched
Show Update the active organization
Organization fields to update
Show Get organization members
returns
Promise<OrganizationMember[]>
List of organization members
Show Get organization roles
returns
Promise<OrganizationRole[]>
List of organization roles
Show Get organization domains
returns
Promise<OrganizationDomain[]>
List of organization domains
Show Add a domain to the organization
returns
Promise<OrganizationDomain>
The added domain
Show Verify an organization domain
returns
Promise<OrganizationDomain>
The verified domain
Show Remove a domain from the organization
Resolves when the domain is removed
Show Remove a member from the organization
Resolves when the member is removed
Show Leave the active organization
Resolves when the organization is left
Show Remove a role from the organization
Resolves when the role is removed
Show Add a role to an organization member
Resolves when the role is added
Show Remove a role from an organization member
Resolves when the role is removed
Show Invite a member to the organization
invitation
OrganizationInvitationPayload
The invitation details
returns
Promise<Invitation | undefined>
The invitation if successful, undefined if no active organization
Email address of the user to invite
invitation.organizationRole
Organization role to assign to the invited user
Optional workspace to also invite the user to
Optional workspace role to assign
Show Discard an organization invitation
The invitation ID to discard
Resolves when the invitation is discarded
Show Resend an organization invitation
The invitation ID to resend
returns
Promise<OrganizationInvitation>
The resent invitation
Show Get organization invitations
returns
Promise<OrganizationInvitation[]>
List of organization invitations
Show Get enterprise SSO connections
returns
Promise<EnterpriseConnection[]>
List of enterprise SSO connections
createEnterpriseConnection
Show Create an enterprise SSO connection
config
EnterpriseConnectionConfig
The SSO connection configuration
returns
Promise<EnterpriseConnection>
The created connection
updateEnterpriseConnection
Show Update an enterprise SSO connection
config
Partial<EnterpriseConnectionConfig>
The configuration updates
returns
Promise<EnterpriseConnection>
The updated connection
deleteEnterpriseConnection
Show Delete an enterprise SSO connection
The connection ID to delete
Resolves when the connection is deleted
testEnterpriseConnectionConfig
Show Test an enterprise SSO connection configuration
config
EnterpriseConnectionConfig
The configuration to test
Test result with success status and checks
Show Test an existing enterprise SSO connection
The connection ID to test
Test result with success status and checks
Show Generate a SCIM token for an enterprise connection
The generated SCIM token information
Show Get the SCIM token for an enterprise connection
The SCIM token information
Show Revoke the SCIM token for an enterprise connection
Resolves when the token is revoked
Examples
Display Active Organization
import { useActiveOrganization } from "@wacht/react-router";
function OrgHeader() {
const { activeOrganization } = useActiveOrganization();
return (
<header>
<h1>{activeOrganization?.name}</h1>
<p>{activeOrganization?.description}</p>
</header>
);
}
Update Organization
import { useActiveOrganization } from "@wacht/react-router";
function OrgSettings() {
const { updateOrganization } = useActiveOrganization();
const handleUpdate = async () => {
await updateOrganization({
name: "Updated Name",
description: "Updated description",
});
};
return <button onClick={handleUpdate}>Update Organization</button>;
}
Get Members
import { useActiveOrganization } from "@wacht/react-router";
function OrgMembers() {
const { getMembers } = useActiveOrganization();
const [members, setMembers] = useState([]);
useEffect(() => {
getMembers().then(setMembers);
}, [getMembers]);
return (
<ul>
{members.map((member) => (
<li key={member.id}>{member.user?.first_name}</li>
))}
</ul>
);
}
Leave Organization
import { useActiveOrganization } from "@wacht/react-router";
function LeaveOrgButton() {
const { leave } = useActiveOrganization();
return (
<button onClick={() => leave()}>
Leave Organization
</button>
);
}
Data Structures
OrganizationInvitationPayload
Email address of the user to invite
Organization role to assign to the invited user
Optional workspace to also invite the user to
Optional workspace role to assign
Unique identifier for the invitation
Email address of the invited user
ID of the organization this invitation belongs to
initial_organization_role
Initial organization role assigned
Associated workspace (if also invited to a workspace)
Initial workspace role assigned
The user who sent this invitation
Whether the invitation has expired
ISO 8601 timestamp when the invitation was created
ISO 8601 timestamp when the invitation was last updated