Capxul Docs
HooksOrganizations

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:

FieldTypeDescription
idOrgIdThe org's identifier. Pass it to every org-scoped hook.
namestringThe org's display name.
handlestringThe globally-unique org handle claimed at creation.
safeAddressAddressThe org account's address.
rolestringYour role label within this org.
treasuryAccountA snapshot of the org's treasury — its balance and available balance.

The hook returns TanStack Query's UseQueryResult. The most-used fields:

FieldDescription
dataThe query data (typed per hook, shown above). undefined until the first success.
errorA CapxulError when the last fetch failed, otherwise null.
status'pending' | 'error' | 'success'.
isLoadingtrue during the first fetch (no data yet).
isFetchingtrue whenever a fetch is in flight, including background refetches.
refetchManually 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.

On this page