useCapxulOrgs
Query hook for the list of organizations the signed-in user belongs to.
Lists the organizations you belong to — one OrgView per org, with its name,
handle, your role inside it, and a treasury snapshot. Pair it with
useCapxulOrg to read a single
org, or useCapxulCreateOrg
to start a new one.
Import
import { useCapxulOrgs } from "@capxul/sdk-react";Usage
"use client";
import { useCapxulOrgs } from "@capxul/sdk-react";
function OrgList() {
const orgs = useCapxulOrgs();
if (orgs.isLoading) return <p>Loading organizations…</p>;
if (orgs.error) return <p>{orgs.error.message}</p>;
return (
<ul>
{orgs.data.map((org) => (
<li key={org.id}>
{org.name} <span>@{org.handle}</span> — your role: {org.role}
</li>
))}
</ul>
);
}Parameters
options
UseCapxulOrgsOptions | undefined
Prop
Type
This is a session-scoped authenticated read. Firing it before the session has
settled surfaces a spurious NOT_AUTHENTICATED error, so gate it on auth
readiness when the surface can render before sign-in completes:
const session = useCapxulSession();
const orgs = useCapxulOrgs({ enabled: session.data !== null });Return type
import { type UseCapxulOrgsReturn } from "@capxul/sdk-react";
// UseQueryResult<readonly OrgView[], CapxulError>data is a list of OrgView records — the orgs you are a member of:
| Field | Type | Description |
|---|---|---|
id | OrgId | The org's identifier. Pass it to every org-scoped hook. |
name | string | The org's display name. |
handle | string | The globally-unique org handle claimed at creation. |
safeAddress | Address | The org account's address. |
role | string | Your role label within this org. |
treasury | Account | A snapshot of the org's treasury — its balance and available balance. |
The hook returns TanStack Query's UseQueryResult. The most-used fields:
| Field | Description |
|---|---|
data | The query data (typed per hook, shown above). undefined until the first success. |
error | A CapxulError when the last fetch failed, otherwise null. |
status | 'pending' | 'error' | 'success'. |
isLoading | true during the first fetch (no data yet). |
isFetching | true whenever a fetch is in flight, including background refetches. |
refetch | Manually refetch the query. |
Capxul query hooks stay pending until the provider finishes bootstrapping —
you do not need to gate them on useCapxul() yourself. The full field list is
in the TanStack Query useQuery reference;
see also the TanStack Query integration guide.
Query key
["capxul", "orgs"] — invalidated on success by
useCapxulCreateOrg and
useCapxulOrgDeployRoles.
Client method
This hook wraps client.orgs() on the core SDK.