Capxul Docs
HooksAuth & session

useCapxulProfile

Query hook for the signed-in user's identity profile — null for a fresh identity until onboarding completes.

Reads the signed-in user's identity profile — display name, country, KYC tier. Distinct from useCapxulSession (am I signed in?) and from useCapxulCurrentUser (the aggregated user + accounts + orgs view).

Import

import { useCapxulProfile } from "@capxul/sdk-react";

Usage

"use client";

import { useCapxulProfile } from "@capxul/sdk-react";

function ProfileCard() {
  const profile = useCapxulProfile();

  if (profile.isLoading) return <p>Loading profile…</p>;
  if (profile.error) return <p>{profile.error.message}</p>;

  if (!profile.data) {
    // Fresh identity — signed in, but onboarding has not completed yet.
    return <a href="/signup">Finish setting up your account</a>;
  }

  return (
    <div>
      <p>{profile.data.displayName ?? profile.data.email}</p>
      <p>Country: {profile.data.country ?? "—"}</p>
    </div>
  );
}

data can be null for a brand-new identity: OTP verification creates the auth user, but the profile record is created during onboarding / account setup, not at verification. Treat null as "route to onboarding", not as an error.

Parameters

None. The query is gated automatically: it stays pending until the provider finishes bootstrapping, with no manual enabled wiring needed.

Return type

import { type UseCapxulProfileReturn } from "@capxul/sdk-react";
// UseQueryResult<Profile | null, CapxulError>

data is a Profile or null (no profile record yet — see above):

FieldTypeDescription
authUserIdstringThe auth user id — same id as Session.authUserId.
emailstringThe signed-in email.
displayNamestring | nullSet during onboarding; null until then.
countrystring | nullISO-3166 country code, set during onboarding.
kycTier0 | 1 | 2 | 3The identity's verification tier.
createdAtnumberEpoch milliseconds.
updatedAtnumberEpoch milliseconds.

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", "profile"] — invalidated (background refetch) by useCapxulVerifyOtp and by the onboarding mutations (useCapxulCompletePersonalOnboarding, useCapxulCompleteOrganizationOnboarding), and reset by useCapxulSignOut.

Client method

This hook wraps client.identity.loadCurrent() on the core SDK.

On this page