> ## Documentation Index
> Fetch the complete documentation index at: https://docs.hexclave.com/llms.txt
> Use this file to discover all available pages before exploring further.

# User

> Reference for CurrentUser, ServerUser, and CurrentServerUser types.

This is a detailed reference for the `User` object. If you're looking for a more high-level overview, please refer to our guide on users [here](https://docs.hexclave.com/guides/getting-started/user-fundamentals.md).On this page:- [CurrentUser](#currentuser)
- [ServerUser](#serveruser)
- [CurrentServerUser](#currentserveruser)# `CurrentUser`Use `useUser()` to get `CurrentUser` (client). Use `hexclaveServerApp.getUser()` to get `CurrentServerUser` (server).## Table of ContentsCurrentUser Table of Contents<pre />## Properties

\<details>

\<summary>`currentUser.id`
          
            
            currentUser</summary>

      

The user ID. This is the unique identifier of the user.

Type Definition

\`typescript declare const id: string; `

\</details>



\<details>

\<summary>`currentUser.displayName`
          
            
            currentUser</summary>

      

The display name of the user, or `null` if not set. The user can modify
this value.

Type Definition

\`typescript declare const displayName: string | null; `

\</details>



\<details>

\<summary>`currentUser.primaryEmail`
          
            
            currentUser</summary>

      

The primary email of the user. Note that this is not necessarily unique.

Type Definition

\`typescript declare const primaryEmail: string | null; `

\</details>



\<details>

\<summary>`currentUser.primaryEmailVerified`
          
            
            currentUser</summary>

      

Whether the primary email of the user is verified.

Type Definition

\`typescript declare const primaryEmailVerified: boolean; `

\</details>



\<details>

\<summary>`currentUser.profileImageUrl`
          
            
            currentUser</summary>

      

The profile image URL of the user, or `null` if no profile image is set.

Type Definition

\`typescript declare const profileImageUrl: string | null; `

\</details>



\<details>

\<summary>`currentUser.signedUpAt`
          
            
            currentUser</summary>

      

The date and time when the user signed up.

Type Definition

\`typescript declare const signedUpAt: Date; `

\</details>



\<details>

\<summary>`currentUser.hasPassword`
          
            
            currentUser</summary>

      

Whether the user has a password set.

Type Definition

\`typescript declare const hasPassword: boolean; `

\</details>



\<details>

\<summary>`currentUser.clientMetadata`
          
            
            currentUser</summary>

      

Client-visible custom metadata. This should not contain sensitive or
server-only information.

Type Definition

\`typescript declare const clientMetadata: Json; `

\</details>



\<details>

\<summary>`currentUser.clientReadOnlyMetadata`
          
            
            currentUser</summary>

      

Read-only metadata visible on the client side. It can only be modified on
the server side.

Type Definition

\`typescript declare const clientReadOnlyMetadata: Json; `

\</details>



\<details>

\<summary>`currentUser.selectedTeam`
          
            
            currentUser</summary>

      

The currently selected team for the user, or `null` if no team is
selected.

Type Definition

\`typescript declare const selectedTeam: Team | null; `

\</details>



\<details>

\<summary>`currentUser.currentSession`
          
            
            currentUser</summary>

      

The current session object, which provides access to authentication tokens.

Type Definition

\```typescript theme={null}
declare const currentSession: {
  getTokens(): Promise<{ accessToken: string | null; refreshToken: string | null }>;
  useTokens(): { accessToken: string | null; refreshToken: string | null };
};
\```

\</details>



\<details>

\<summary>`currentUser.otpAuthEnabled`
          
            
            currentUser</summary>

      

Whether OTP (one-time password) authentication is enabled for this user.

Type Definition

\`typescript declare const otpAuthEnabled: boolean; `

\</details>



\<details>

\<summary>`currentUser.passkeyAuthEnabled`
          
            
            currentUser</summary>

      

Whether passkey authentication is enabled for this user.

Type Definition

\`typescript declare const passkeyAuthEnabled: boolean; `

\</details>



\<details>

\<summary>`currentUser.isMultiFactorRequired`
          
            
            currentUser</summary>

      

Whether multi-factor authentication is required for this user.

Type Definition

\`typescript declare const isMultiFactorRequired: boolean; `

\</details>



\<details>

\<summary>`currentUser.isAnonymous`
          
            
            currentUser</summary>

      

Whether this is an anonymous user (signed in without credentials).

Type Definition

\`typescript declare const isAnonymous: boolean; `

\</details>



\<details>

\<summary>`currentUser.isRestricted`
          
            
            currentUser</summary>

      

Whether the user is restricted from performing certain actions.

Type Definition

\`typescript declare const isRestricted: boolean; `

\</details>



\<details>

\<summary>`currentUser.restrictedReason`
          
            
            currentUser</summary>

      

The reason why the user is restricted, or `null` if the user is not restricted.

Type Definition

\```typescript theme={null}
declare const restrictedReason: {
  type: "anonymous" | "email_not_verified" | "restricted_by_administrator";
} | null;
\```

\</details>

## Profile Management

\<details>

\<summary>`currentUser.update(data)`
          
            
            currentUser</summary>

      

Updates multiple fields of the user at once.

Parameters

\**data** `object` *required*

The fields to update on the user.

\**displayName** `string | null`

The new display name for the user.

\**clientMetadata** `ReadonlyJson`

Custom metadata visible to the client.

\**selectedTeamId** `string | null`

The ID of the team to set as selected, or `null` to clear selection.

\**profileImageUrl** `string | null`

The URL of the user's new profile image, or `null` to remove it.

\**totpMultiFactorSecret** `Uint8Array | null`

The TOTP multi-factor authentication secret, or `null` to disable.

\**otpAuthEnabled** `boolean`

Whether to enable OTP authentication.

\**passkeyAuthEnabled** `boolean`

Whether to enable passkey authentication.

\**primaryEmail** `string | null`

The new primary email address.

Returns

\`Promise<void>`

Signature

\```typescript theme={null}
declare function update(data: {
  displayName?: string | null;
  clientMetadata?: ReadonlyJson;
  selectedTeamId?: string | null;
  profileImageUrl?: string | null;
  totpMultiFactorSecret?: Uint8Array | null;
  otpAuthEnabled?: boolean;
  passkeyAuthEnabled?: boolean;
  primaryEmail?: string | null;
}): Promise<void>;
\```

Examples

\```typescript theme={null}
await user.update({
  displayName: "New Display Name",
  clientMetadata: {
    address: "123 Main St",
  },
});
\```

\</details>



\<details>

\<summary>`currentUser.setDisplayName(displayName)`
          
            
            currentUser</summary>

      

Sets the display name of the user.

Parameters

\**displayName** `string | null` *required*

The new display name, or `null` to clear it.

Returns

\`Promise<void>`

Signature

\```typescript theme={null}
declare function setDisplayName(displayName: string | null): Promise<void>;
\```

Examples

\```typescript theme={null}
await user.setDisplayName("John Doe");
\```

\</details>



\<details>

\<summary>`currentUser.setClientMetadata(metadata)`
          
            
            currentUser</summary>

      

Sets the client metadata for the user.

Parameters

\**metadata** `Json` *required*

The new client metadata value.

Returns

\`Promise<void>`

Signature

\```typescript theme={null}
declare function setClientMetadata(metadata: any): Promise<void>;
\```

Examples

\```typescript theme={null}
await user.setClientMetadata({ theme: "dark", locale: "en" });
\```

\</details>



\<details>

\<summary>`currentUser.updatePassword(data)`
          
            
            currentUser</summary>

      

Changes password with old and new password validation.

Parameters

\**data** `object` *required*

Password change inputs.

\**oldPassword** `string` *required*

The user's current password.

\**newPassword** `string` *required*

The new password to set.

Returns

\`Promise<void>`

Signature

\```typescript theme={null}
declare function updatePassword(data: {
  oldPassword: string;
  newPassword: string;
}): Promise<void>;
\```

Examples

\```typescript theme={null}
await user.updatePassword({
  oldPassword: "old-password",
  newPassword: "new-password",
});
\```

\</details>



\<details>

\<summary>`currentUser.setPassword(options)`
          
            
            currentUser</summary>

      

Sets a password for the user without requiring the current password.

Parameters

\**options.password** `string` *required*

The new password to set.

Returns

\`Promise<void>`

Signature

\```typescript theme={null}
declare function setPassword(options: {
  password: string;
}): Promise<void>;
\```

Examples

\```typescript theme={null}
await user.setPassword({ password: "new-secure-password" });
\```

\</details>



\<details>

\<summary>`currentUser.toClientJson`
          
            
            currentUser</summary>

      

Converts the user object to the format expected by the Hexclave API. Useful for serializing user data in API responses or caching.

Returns

\`CurrentUserCrud["Client"]["Read"]`

Signature

\```typescript theme={null}
declare function toClientJson(): CurrentUserCrud["Client"]["Read"];
\```

Examples

\```typescript theme={null}
const user = useUser();
const json = user.toClientJson();
localStorage.setItem("cachedUser", JSON.stringify(json));
\```

\</details>

## Authentication

\<details>

\<summary>`currentUser.getAuthorizationHeader`
          
            
            currentUser</summary>

      

Returns the HTTP `Authorization` header value in `Bearer stackauth_...` format for authenticated requests.
Returns `null` if the user is not signed in.

Returns

\`Promise<string | null>`

Signature

\```typescript theme={null}
declare function getAuthorizationHeader(): Promise<string | null>;
\```

\</details>



\<details>

\<summary>`currentUser.useAuthorizationHeader`
          
            
            currentUser</summary>

      

React hook that returns the HTTP `Authorization` header value in `Bearer stackauth_...` format.
Returns `null` if the user is not signed in.

Returns

\`string | null`

Signature

\```typescript theme={null}
declare function useAuthorizationHeader(): string | null;
\```

\</details>



\<details>

\<summary>`currentUser.getAuthHeaders`
          
            
            currentUser</summary>

      

\**Deprecated:** Use `getAuthorizationHeader()` instead.

Returns legacy `x-stack-auth` headers for cross-origin authenticated requests.

Returns

\`Promise<Record<string, string>>`

Signature

\```typescript theme={null}
declare function getAuthHeaders(): Promise<Record<string, string>>;
\```

\</details>



\<details>

\<summary>`currentUser.useAuthHeaders`
          
            
            currentUser</summary>

      

\**Deprecated:** Use `useAuthorizationHeader()` instead.

React hook that returns legacy `x-stack-auth` headers for cross-origin requests.

Returns

\`Record<string, string>`

Signature

\```typescript theme={null}
declare function useAuthHeaders(): Record<string, string>;
\```

\</details>



\<details>

\<summary>`currentUser.getAccessToken`
          
            
            currentUser</summary>

      

Returns the current access token, or `null` if the user is not signed in. The access token is a short-lived JWT that is automatically refreshed when it expires.

Returns

\`Promise<string | null>`

Signature

\```typescript theme={null}
declare function getAccessToken(): Promise<string | null>;
\```

\</details>



\<details>

\<summary>`currentUser.useAccessToken`
          
            
            currentUser</summary>

      

React hook that returns the current access token, or `null` if not signed in.

Returns

\`string | null`

Signature

\```typescript theme={null}
declare function useAccessToken(): string | null;
\```

\</details>



\<details>

\<summary>`currentUser.getRefreshToken`
          
            
            currentUser</summary>

      

Returns the current refresh token, or `null` if the user is not signed in. The refresh token is a long-lived token used to obtain new access tokens.

Returns

\`Promise<string | null>`

Signature

\```typescript theme={null}
declare function getRefreshToken(): Promise<string | null>;
\```

\</details>



\<details>

\<summary>`currentUser.useRefreshToken`
          
            
            currentUser</summary>

      

React hook that returns the current refresh token, or `null` if not signed in.

Returns

\`string | null`

Signature

\```typescript theme={null}
declare function useRefreshToken(): string | null;
\```

\</details>



\<details>

\<summary>`currentUser.signOut([options])`
          
            
            currentUser</summary>

      

Signs out the user with an optional redirect URL.

Parameters

\**options.redirectUrl** `string`

URL to redirect to after sign-out.

Returns

\`Promise<void>`

Signature

\```typescript theme={null}
declare function signOut(options?: {
  redirectUrl?: string;
}): Promise<void>;
\```

\</details>



\<details>

\<summary>`currentUser.delete`
          
            
            currentUser</summary>

      

Permanently deletes the user account. Requires client-side deletion to be enabled in the project settings.

Returns

\`Promise<void>`

Signature

\```typescript theme={null}
declare function delete(): Promise<void>;
\```

\</details>

## Team Management

\<details>

\<summary>`currentUser.getTeam(id)`
          
            
            currentUser</summary>

      

Gets the team with the specified ID.

Parameters

\**id** `string` *required*

The ID of the team to get.

Returns

\`Promise<Team | null>`

The team object, or `null` if the team is not found or the user is not a member.

Signature

\```typescript theme={null}
declare function getTeam(id: string): Promise<Team | null>;
\```

Examples

\```typescript theme={null}
const team = await user.getTeam("teamId");
\```

\</details>



\<details>

\<summary>`currentUser.useTeam(id)`
          
            
            currentUser</summary>

      

React hook version of `getTeam`.

Parameters

\**id** `string` *required*

The ID of the team to get.

Returns

\`Team | null`

Signature

\```typescript theme={null}
declare function useTeam(id: string): Team | null;
\```

\</details>



\<details>

\<summary>`currentUser.listTeams`
          
            
            currentUser</summary>

      

Lists the teams the user is a member of.

If there are more teams than the requested `limit`, `nextCursor` on the result is set; pass it as `cursor` (together with `limit`) to fetch the next page. Otherwise, `nextCursor` is `null`.

Parameters

\**options.limit** `number`

The maximum number of teams to return (at most 200). If omitted, all teams are returned, but the request fails if the user is in more than 500 teams, so prefer setting `limit`.

\**options.cursor** `string`

The `nextCursor` of the previous page. Requires `limit` to also be set.

\**options.query** `string`

Free-text search. Matches the team ID exactly, or part of the display name.

\**options.orderBy** `"createdAt"`

The field to sort results by.

\**options.desc** `boolean`

Whether to sort in descending order. Defaults to `false`.

Returns

\`Promise<Team[] & { nextCursor: string | null }>`

Signature

\```typescript theme={null}
declare function listTeams(options?: {
  limit?: number;
  cursor?: string;
  query?: string;
  orderBy?: "createdAt";
  desc?: boolean;
}): Promise<Team[] & { nextCursor: string | null }>;
\```

Examples

\```typescript theme={null}
// Page through all teams
const allTeams = [];
let cursor: string | undefined = undefined;
do {
  const page = await user.listTeams({ limit: 100, cursor });
  allTeams.push(...page);
  cursor = page.nextCursor ?? undefined;
} while (cursor != null);
\```

\</details>



\<details>

\<summary>`currentUser.useTeams`
          
            
            currentUser</summary>

      

React hook version of `listTeams`. Accepts the same options.

Returns

\`Team[] & { nextCursor: string | null }`

Signature

\```typescript theme={null}
declare function useTeams(options?: {
  limit?: number;
  cursor?: string;
  query?: string;
  orderBy?: "createdAt";
  desc?: boolean;
}): Team[] & { nextCursor: string | null };
\```

\</details>



\<details>

\<summary>`currentUser.setSelectedTeam(team)`
          
            
            currentUser</summary>

      

Sets the currently selected team for the user.

Parameters

\**team** `Team | null` *required*

The team to set as selected, or `null` to clear selection.

Returns

\`Promise<void>`

Signature

\```typescript theme={null}
declare function setSelectedTeam(team: Team | null): Promise<void>;
\```

Examples

\```typescript theme={null}
const team = await user.getTeam("team_id_123");
await user.setSelectedTeam(team);
\```

\</details>



\<details>

\<summary>`currentUser.createTeam(data)`
          
            
            currentUser</summary>

      

Creates a new team for the user. The user will be added to the team and given creator permissions.

Parameters

\**data** `object` *required*

Team creation options.

\**displayName** `string`

The display name for the team.

\**profileImageUrl** `string | null`

The URL of the team's profile image.

Returns

\`Promise<Team>`

\> \\[!NOTE]
\>
\> If client-side team creation is disabled in the Stack dashboard, this will throw an error.

Signature

\```typescript theme={null}
declare function createTeam(data: {
  displayName?: string;
  profileImageUrl?: string | null;
}): Promise<Team>;
\```

\</details>



\<details>

\<summary>`currentUser.leaveTeam(team)`
          
            
            currentUser</summary>

      

Removes the user from the specified team.

Parameters

\**team** `Team` *required*

The team to leave.

Returns

\`Promise<void>`

Signature

\```typescript theme={null}
declare function leaveTeam(team: Team): Promise<void>;
\```

\</details>



\<details>

\<summary>`currentUser.getTeamProfile(team)`
          
            
            currentUser</summary>

      

Retrieves the user's profile within a specific team.

Parameters

\**team** `Team` *required*

The team to get the profile for.

Returns

\`Promise<EditableTeamMemberProfile>`

Signature

\```typescript theme={null}
declare function getTeamProfile(team: Team): Promise<EditableTeamMemberProfile>;
\```

\</details>



\<details>

\<summary>`currentUser.useTeamProfile(team)`
          
            
            currentUser</summary>

      

React hook version of `getTeamProfile`.

Parameters

\**team** `Team` *required*

The team to get the profile for.

Returns

\`EditableTeamMemberProfile`

Signature

\```typescript theme={null}
declare function useTeamProfile(team: Team): EditableTeamMemberProfile;
\```

\</details>



\<details>

\<summary>`currentUser.listTeamInvitations`
          
            
            currentUser</summary>

      

Lists all pending team invitations sent to any of the current user's verified email addresses.

Returns

\`Promise<ReceivedTeamInvitation[]>`

Signature

\```typescript theme={null}
declare function listTeamInvitations(): Promise<ReceivedTeamInvitation[]>;
\```

\</details>



\<details>

\<summary>`currentUser.useTeamInvitations`
          
            
            currentUser</summary>

      

React hook version of `listTeamInvitations`. Automatically re-renders when invitations change.

Returns

\`ReceivedTeamInvitation[]`

Signature

\```typescript theme={null}
declare function useTeamInvitations(): ReceivedTeamInvitation[];
\```

\</details>

## Permissions

\<details>

\<summary>`currentUser.hasPermission(scope, permissionId)`
          
            
            currentUser</summary>

      

Checks if the user has a specific permission within a team.

Parameters

\**scope** `Team` *required*

The team scope.

\**permissionId** `string` *required*

The permission identifier.

Returns

\`Promise<boolean>`

Signature

\```typescript theme={null}
declare function hasPermission(scope: Team, permissionId: string): Promise<boolean>;
\```

\</details>



\<details>

\<summary>`currentUser.getPermission(scope, permissionId, [options])`
          
            
            currentUser</summary>

      

Retrieves a specific permission with optional recursive lookup.

Parameters

\**scope** `Team` *required*

The team scope.

\**permissionId** `string` *required*

The permission identifier.

\**options.recursive** `boolean`

Whether to look up permissions recursively.

Returns

\`Promise<TeamPermission | null>`

Signature

\```typescript theme={null}
declare function getPermission(
  scope: Team,
  permissionId: string,
  options?: { recursive?: boolean },
): Promise<TeamPermission | null>;
\```

\</details>



\<details>

\<summary>`currentUser.usePermission(scope, permissionId, [options])`
          
            
            currentUser</summary>

      

React hook version of `getPermission`.

Parameters

\**scope** `Team` *required*

The team scope.

\**permissionId** `string` *required*

The permission identifier.

\**options.recursive** `boolean`

Whether to look up permissions recursively.

Returns

\`TeamPermission | null`

Signature

\```typescript theme={null}
declare function usePermission(
  scope: Team,
  permissionId: string,
  options?: { recursive?: boolean },
): TeamPermission | null;
\```

\</details>



\<details>

\<summary>`currentUser.listPermissions(scope, [options])`
          
            
            currentUser</summary>

      

Lists all permissions for a team.

Parameters

\**scope** `Team` *required*

The team scope.

\**options.recursive** `boolean`

Whether to list permissions recursively.

Returns

\`Promise<TeamPermission[]>`

Signature

\```typescript theme={null}
declare function listPermissions(
  scope: Team,
  options?: { recursive?: boolean },
): Promise<TeamPermission[]>;
\```

\</details>



\<details>

\<summary>`currentUser.usePermissions(scope, [options])`
          
            
            currentUser</summary>

      

React hook version of `listPermissions`.

Parameters

\**scope** `Team` *required*

The team scope.

\**options.recursive** `boolean`

Whether to list permissions recursively.

Returns

\`TeamPermission[]`

Signature

\```typescript theme={null}
declare function usePermissions(
  scope: Team,
  options?: { recursive?: boolean },
): TeamPermission[];
\```

\</details>

## Contact Channels

\<details>

\<summary>`currentUser.listContactChannels`
          
            
            currentUser</summary>

      

Lists the user's contact channels.

Returns

\`Promise<ContactChannel[]>`

Signature

\```typescript theme={null}
declare function listContactChannels(): Promise<ContactChannel[]>;
\```

\</details>



\<details>

\<summary>`currentUser.useContactChannels`
          
            
            currentUser</summary>

      

React hook version of `listContactChannels`.

Returns

\`ContactChannel[]`

Signature

\```typescript theme={null}
declare function useContactChannels(): ContactChannel[];
\```

\</details>



\<details>

\<summary>`currentUser.createContactChannel(data)`
          
            
            currentUser</summary>

      

Creates a new contact channel for the user.

Parameters

\**data** `object` *required*

Contact channel creation options.

\**value** `string` *required*

The value of the contact channel (e.g., email address).

\**type** `"email"` *required*

The type of contact channel. Currently always `"email"`.

\**usedForAuth** `boolean` *required*

Whether this contact channel can be used for authentication.

\**isPrimary** `boolean`

Whether this should be set as the user's primary contact channel.

Returns

\`Promise<ContactChannel>`

Signature

\```typescript theme={null}
declare function createContactChannel(data: {
  value: string;
  type: "email";
  usedForAuth: boolean;
  isPrimary?: boolean;
}): Promise<ContactChannel>;
\```

Examples

\```typescript theme={null}
const channel = await user.createContactChannel({
  type: "email",
  value: "backup@example.com",
  usedForAuth: true,
});
\```

\</details>



\<details>

\<summary>`currentUser.listNotificationCategories`
          
            
            currentUser</summary>

      

Lists all notification categories.

Returns

\`Promise<NotificationCategory[]>`

Signature

\```typescript theme={null}
declare function listNotificationCategories(): Promise<NotificationCategory[]>;
\```

\</details>



\<details>

\<summary>`currentUser.useNotificationCategories`
          
            
            currentUser</summary>

      

React hook to get all notification categories.

Returns

\`NotificationCategory[]`

Signature

\```typescript theme={null}
declare function useNotificationCategories(): NotificationCategory[];
\```

\</details>

## OAuth Connections

\<details>

\<summary>`currentUser.listConnectedAccounts`
          
            
            currentUser</summary>

      

Lists all connected accounts.

Returns

\`Promise<OAuthConnection[]>`

Signature

\```typescript theme={null}
declare function listConnectedAccounts(): Promise<OAuthConnection[]>;
\```

\</details>



\<details>

\<summary>`currentUser.useConnectedAccounts`
          
            
            currentUser</summary>

      

React hook version of `listConnectedAccounts`.

Returns

\`OAuthConnection[]`

Signature

\```typescript theme={null}
declare function useConnectedAccounts(): OAuthConnection[];
\```

\</details>



\<details>

\<summary>`currentUser.linkConnectedAccount(provider, [options])`
          
            
            currentUser</summary>

      

Initiates an OAuth flow to link a new account.

Parameters

\**provider** `string` *required*

The OAuth provider.

\**options.scopes** `string[]`

Requested scopes.

Returns

\`Promise<void>`

Signature

\```typescript theme={null}
declare function linkConnectedAccount(
  provider: string,
  options?: { scopes?: string[] },
): Promise<void>;
\```

Examples

\```typescript theme={null}
await user.linkConnectedAccount("google", {
  scopes: ["email", "profile"],
});
\```

\</details>



\<details>

\<summary>`currentUser.getOrLinkConnectedAccount(provider, [options])`
          
            
            currentUser</summary>

      

Gets an existing connected account or redirects to link if it is missing or has insufficient scopes.

Parameters

\**provider** `string` *required*

The OAuth provider.

\**options.scopes** `string[]`

Requested scopes.

Returns

\`Promise<OAuthConnection>`

Signature

\```typescript theme={null}
declare function getOrLinkConnectedAccount(
  provider: string,
  options?: { scopes?: string[] },
): Promise<OAuthConnection>;
\```

Examples

\```typescript theme={null}
const googleConnection = await user.getOrLinkConnectedAccount("google", {
  scopes: ["email", "profile"],
});
\```

\</details>



\<details>

\<summary>`currentUser.useOrLinkConnectedAccount(provider, [options])`
          
            
            currentUser</summary>

      

React hook version of `getOrLinkConnectedAccount`.

Parameters

\**provider** `string` *required*

The OAuth provider.

\**options.scopes** `string[]`

Requested scopes.

Returns

\`OAuthConnection`

Signature

\```typescript theme={null}
declare function useOrLinkConnectedAccount(
  provider: string,
  options?: { scopes?: string[] },
): OAuthConnection;
\```

\</details>



\<details>

\<summary>`currentUser.getOAuthProvider(id)`
          
            
            currentUser</summary>

      

Gets a specific OAuth provider by ID.

Parameters

\**id** `string` *required*

The OAuth provider ID.

Returns

\`Promise<OAuthProvider | null>`

Signature

\```typescript theme={null}
declare function getOAuthProvider(id: string): Promise<OAuthProvider | null>;
\```

\</details>



\<details>

\<summary>`currentUser.useOAuthProvider(id)`
          
            
            currentUser</summary>

      

React hook to get a specific OAuth provider by ID.

Parameters

\**id** `string` *required*

The OAuth provider ID.

Returns

\`OAuthProvider | null`

Signature

\```typescript theme={null}
declare function useOAuthProvider(id: string): OAuthProvider | null;
\```

\</details>



\<details>

\<summary>`currentUser.listOAuthProviders`
          
            
            currentUser</summary>

      

Lists all OAuth providers connected to the user.

Returns

\`Promise<OAuthProvider[]>`

Signature

\```typescript theme={null}
declare function listOAuthProviders(): Promise<OAuthProvider[]>;
\```

\</details>



\<details>

\<summary>`currentUser.useOAuthProviders`
          
            
            currentUser</summary>

      

React hook to get all OAuth providers connected to the user.

Returns

\`OAuthProvider[]`

Signature

\```typescript theme={null}
declare function useOAuthProviders(): OAuthProvider[];
\```

\</details>

## Passkeys & Sessions

\<details>

\<summary>`currentUser.registerPasskey([options])`
          
            
            currentUser</summary>

      

Registers a passkey for the user for passwordless authentication.

Parameters

\**options.hostname** `string`

The hostname to associate with the passkey.

Returns

\`Promise<Result<undefined, KnownErrors>>`

Signature

\```typescript theme={null}
declare function registerPasskey(options?: {
  hostname?: string;
}): Promise<Result<undefined, KnownErrors["PasskeyRegistrationFailed"] | KnownErrors["PasskeyWebAuthnError"]>>;
\```

\</details>



\<details>

\<summary>`currentUser.getActiveSessions`
          
            
            currentUser</summary>

      

Gets all active sessions for the user.

Returns

\`Promise<ActiveSession[]>`

Signature

\```typescript theme={null}
declare function getActiveSessions(): Promise<ActiveSession[]>;
\```

\</details>



\<details>

\<summary>`currentUser.revokeSession(sessionId)`
          
            
            currentUser</summary>

      

Revokes a specific session for the user.

Parameters

\**sessionId** `string` *required*

The ID of the session to revoke.

Returns

\`Promise<void>`

Signature

\```typescript theme={null}
declare function revokeSession(sessionId: string): Promise<void>;
\```

\</details>

## API Keys

\<details>

\<summary>`currentUser.createApiKey(options)`
          
            
            currentUser</summary>

      

Creates a new API key.

Parameters

\**options** `object` *required*

API key creation options.

\**description** `string` *required*

Purpose explanation for the key.

\**expiresAt** `Date | null` *required*

Expiration date, or `null` for no expiration.

\**isPublic** `boolean`

Defaults to `false`. Secret keys are scanned for exposure.

Returns

\`Promise<UserApiKeyFirstView>`

Signature

\```typescript theme={null}
declare function createApiKey(options: {
  description: string;
  expiresAt: Date | null;
  isPublic?: boolean;
}): Promise<UserApiKeyFirstView>;
\```

Examples

\```typescript theme={null}
const apiKey = await user.createApiKey({
  description: "CI token",
  expiresAt: null,
});
console.log(apiKey);
\```

\</details>



\<details>

\<summary>`currentUser.listApiKeys`
          
            
            currentUser</summary>

      

Lists the user's API keys.

Returns

\`Promise<UserApiKey[]>`

Signature

\```typescript theme={null}
declare function listApiKeys(): Promise<UserApiKey[]>;
\```

\</details>



\<details>

\<summary>`currentUser.useApiKeys`
          
            
            currentUser</summary>

      

React hook version of `listApiKeys`.

Returns

\`UserApiKey[]`

Signature

\```typescript theme={null}
declare function useApiKeys(): UserApiKey[];
\```

\</details>

## Billing & Payments

\<details>

\<summary>`currentUser.createCheckoutUrl(options)`
          
            
            currentUser</summary>

      

Generates a Stripe checkout URL for purchasing a product.

Parameters

\**options.productId** `string`

The ID of the product to purchase.

Returns

\`Promise<string>`

Signature

\```typescript theme={null}
declare function createCheckoutUrl(options: {
  productId: string;
}): Promise<string>;
\```

Examples

\```typescript theme={null}
const checkoutUrl = await user.createCheckoutUrl({
  productId: "prod_premium_monthly",
});
window.location.href = checkoutUrl;
\```

\</details>



\<details>

\<summary>`currentUser.getItem(itemId)`
          
            
            currentUser</summary>

      

Retrieves item details such as credits or subscriptions.

Parameters

\**itemId** `string`

The ID of the item to retrieve.

Returns

\`Promise<Item>`

Signature

\```typescript theme={null}
declare function getItem(itemId: string): Promise<Item>;
\```

\</details>



\<details>

\<summary>`currentUser.useItem(itemId)`
          
            
            currentUser</summary>

      

React hook version of `getItem`.

Parameters

\**itemId** `string`

The ID of the item to retrieve.

Returns

\`Item`

Signature

\```typescript theme={null}
declare function useItem(itemId: string): Item;
\```

\</details>



\<details>

\<summary>`currentUser.createPaymentMethodSetupIntent`
          
            
            currentUser</summary>

      

Creates a Stripe setup intent for adding a payment method.

Returns

\`Promise<CustomerPaymentMethodSetupIntent>`

Signature

\```typescript theme={null}
declare function createPaymentMethodSetupIntent(): Promise<CustomerPaymentMethodSetupIntent>;
\```

\</details>



\<details>

\<summary>`currentUser.setDefaultPaymentMethodFromSetupIntent(setupIntentId)`
          
            
            currentUser</summary>

      

Sets the default payment method from a completed setup intent.

Parameters

\**setupIntentId** `string` *required*

The ID of the completed setup intent.

Returns

\`Promise<CustomerDefaultPaymentMethod>`

Signature

\```typescript theme={null}
declare function setDefaultPaymentMethodFromSetupIntent(
  setupIntentId: string,
): Promise<CustomerDefaultPaymentMethod>;
\```

\</details>



\<details>

\<summary>`currentUser.switchSubscription(options)`
          
            
            currentUser</summary>

      

Switches a subscription from one product to another.

Parameters

\**options** `object` *required*

Subscription switch options.

\**fromProductId** `string` *required*

The product ID to switch from.

\**toProductId** `string` *required*

The product ID to switch to.

\**priceId** `string`

A specific price ID to use.

\**quantity** `number`

The quantity for the new subscription.

Returns

\`Promise<void>`

Signature

\```typescript theme={null}
declare function switchSubscription(options: {
  fromProductId: string;
  toProductId: string;
  priceId?: string;
  quantity?: number;
}): Promise<void>;
\```

\</details>



\<details>

\<summary>`currentUser.getBilling`
          
            
            currentUser</summary>

      

Returns the billing information for the user.

Returns

\`Promise<CustomerBilling>`

Signature

\```typescript theme={null}
declare function getBilling(): Promise<CustomerBilling>;
\```

\</details>



\<details>

\<summary>`currentUser.useBilling`
          
            
            currentUser</summary>

      

React hook that returns the billing information.

Returns

\`CustomerBilling`

Signature

\```typescript theme={null}
declare function useBilling(): CustomerBilling;
\```

\</details>



\<details>

\<summary>`currentUser.listProducts([options])`
          
            
            currentUser</summary>

      

Returns all products available to the user.

Returns

\`Promise<CustomerProductsList>`

Signature

\```typescript theme={null}
declare function listProducts(options?: CustomerProductsListOptions): Promise<CustomerProductsList>;
\```

\</details>



\<details>

\<summary>`currentUser.useProducts([options])`
          
            
            currentUser</summary>

      

React hook that returns all products.

Returns

\`CustomerProductsList`

Signature

\```typescript theme={null}
declare function useProducts(options?: CustomerProductsListOptions): CustomerProductsList;
\```

\</details>



\<details>

\<summary>`currentUser.listInvoices([options])`
          
            
            currentUser</summary>

      

Returns all invoices for the user.

Returns

\`Promise<CustomerInvoicesList>`

Signature

\```typescript theme={null}
declare function listInvoices(options?: CustomerInvoicesListOptions): Promise<CustomerInvoicesList>;
\```

\</details>



\<details>

\<summary>`currentUser.useInvoices([options])`
          
            
            currentUser</summary>

      

React hook that returns all invoices.

Returns

\`CustomerInvoicesList`

Signature

\```typescript theme={null}
declare function useInvoices(options?: CustomerInvoicesListOptions): CustomerInvoicesList;
\```

\</details>

## Deprecated

\<details>

\<summary>`currentUser.emailAuthEnabled`
          
            deprecated
            currentUser</summary>

      

Whether email-based authentication is enabled for this user.

\> \\[!WARNING]
\>
\> **Deprecated:** Use contact channel's `usedForAuth` instead.

Type Definition

\`typescript declare const emailAuthEnabled: boolean; `

\</details>



\<details>

\<summary>`currentUser.oauthProviders`
          
            deprecated
            currentUser</summary>

      

The OAuth providers connected to this user account.

\> \\[!WARNING]
\>
\> **Deprecated:** Use `getConnectedAccount()` instead.

Type Definition

\`typescript declare const oauthProviders: readonly { id: string }[]; `

\</details>



\<details>

\<summary>`currentUser.sendVerificationEmail`
          
            deprecated
            currentUser</summary>

      

Sends a verification email to the user's primary email address.

\> \\[!WARNING]
\>
\> **Deprecated:** Use contact channel's `sendVerificationEmail` instead.

Returns

\`Promise<void>`

Signature

\```typescript theme={null}
declare function sendVerificationEmail(): Promise<void>;
\```

\</details>



\<details>

\<summary>`currentUser.getAuthJson`
          
            deprecated
            currentUser</summary>

      

Returns a JSON object with `accessToken` for non-HTTP protocols.

\> \\[!WARNING]
\>
\> **Deprecated:** Use `getAccessToken()` and `getRefreshToken()` instead.

Returns

\`Promise<{ accessToken: string | null }>`

Signature

\```typescript theme={null}
declare function getAuthJson(): Promise<{ accessToken: string | null }>;
\```

\</details>



\<details>

\<summary>`currentUser.useAuthJson`
          
            deprecated
            currentUser</summary>

      

React hook that returns the auth JSON.

\> \\[!WARNING]
\>
\> **Deprecated:** Use `useAccessToken()` and `useRefreshToken()` instead.

Returns

\`{ accessToken: string | null, refreshToken: string | null }`

Signature

\```typescript theme={null}
declare function useAuthJson(): { accessToken: string | null; refreshToken: string | null };
\```

\</details>



\<details>

\<summary>`currentUser.getConnectedAccount(account)`
          
            deprecated
            currentUser</summary>

      

Retrieves a specific connected account.

\> \\[!WARNING]
\>
\> **Deprecated:** Use `getOrLinkConnectedAccount` for redirect behavior, or `getConnectedAccount(\\{ provider, providerAccountId \\})` for existence check.

Parameters

\**account** `object` *required*

Connected account identifier.

\**provider** `string` *required*

The provider identifier.

\**providerAccountId** `string` *required*

The provider account identifier.

Returns

\`Promise<OAuthConnection | null>`

Signature

\```typescript theme={null}
declare function getConnectedAccount(account: {
  provider: string;
  providerAccountId: string;
}): Promise<OAuthConnection | null>;
\```

\</details>



\<details>

\<summary>`currentUser.useConnectedAccount(account)`
          
            deprecated
            currentUser</summary>

      

React hook version of `getConnectedAccount`.

\> \\[!WARNING]
\>
\> **Deprecated:** Use `useOrLinkConnectedAccount` for redirect behavior, or `useConnectedAccount(\\{ provider, providerAccountId \\})` for existence check.

Parameters

\**account** `object` *required*

Connected account identifier.

\**provider** `string` *required*

The provider identifier.

\**providerAccountId** `string` *required*

The provider account identifier.

Returns

\`OAuthConnection | null`

Signature

\```typescript theme={null}
declare function useConnectedAccount(account: {
  provider: string;
  providerAccountId: string;
}): OAuthConnection | null;
\```

\</details>

***# `ServerUser`Accessible via `hexclaveServerApp.getUser()` on the server. `ServerUser` inherits most `CurrentUser` functionality minus session-dependent methods like `getAuthJson()` and `signOut()`.## Table of ContentsServerUser Table of Contents<pre />## Additional Properties

\<details>

\<summary>`serverUser.lastActiveAt`
          
            
            serverUser</summary>

      

Last user activity timestamp.

Type Definition

\`typescript declare const lastActiveAt: Date; `

\</details>



\<details>

\<summary>`serverUser.selectedTeam`
          
            
            serverUser</summary>

      

The currently selected team as a `ServerTeam`, or `null` if no team is selected. Server-only functionality,
such as `addUser()` or the full member details returned by `listUsers()`, is available on it directly,
without fetching the team again with `hexclaveServerApp.getTeam()`.

Type Definition

\`typescript declare const selectedTeam: ServerTeam | null; `

\</details>



\<details>

\<summary>`serverUser.serverMetadata`
          
            
            serverUser</summary>

      

Server-only accessible metadata.

Type Definition

\`typescript declare const serverMetadata: Json; `

\</details>



\<details>

\<summary>`serverUser.restrictedByAdmin`
          
            
            serverUser</summary>

      

Whether the user has been restricted by an administrator.

Type Definition

\`typescript declare const restrictedByAdmin: boolean; `

\</details>



\<details>

\<summary>`serverUser.restrictedByAdminReason`
          
            
            serverUser</summary>

      

The public reason why the user was restricted by an admin, or `null` if not restricted.

Type Definition

\`typescript declare const restrictedByAdminReason: string | null; `

\</details>



\<details>

\<summary>`serverUser.restrictedByAdminPrivateDetails`
          
            
            serverUser</summary>

      

Private details about the admin restriction (only visible server-side), or `null` if not restricted.

Type Definition

\`typescript declare const restrictedByAdminPrivateDetails: string | null; `

\</details>



\<details>

\<summary>`serverUser.countryCode`
          
            
            serverUser</summary>

      

The country code of the user based on their IP address, or `null` if unknown.

Type Definition

\`typescript declare const countryCode: string | null; `

\</details>



\<details>

\<summary>`serverUser.riskScores`
          
            
            serverUser</summary>

      

Risk scores computed during sign-up, useful for fraud detection.

Type Definition

\```typescript theme={null}
declare const riskScores: {
  readonly signUp: {
    readonly bot: number;
    readonly freeTrialAbuse: number;
  };
};
\```

\</details>

## Additional Methods

\<details>

\<summary>`serverUser.update(data)`
          
            
            serverUser</summary>

      

Extended update supporting server-only fields.

Parameters

\**data** `ServerUserUpdateOptions` *required*

The fields to update on the user.

\**displayName** `string | null`

Display name.

\**primaryEmail** `string | null`

Set the primary email.

\**primaryEmailVerified** `boolean`

Set email verification status.

\**primaryEmailAuthEnabled** `boolean`

Enable or disable email auth.

\**password** `string`

Set a new password.

\**clientMetadata** `Json`

Client metadata.

\**clientReadOnlyMetadata** `Json`

Client read-only metadata.

\**serverMetadata** `Json`

Server-only metadata.

\**selectedTeamId** `string | null`

Selected team ID.

\**profileImageUrl** `string | null`

Profile image URL.

\**totpMultiFactorSecret** `Uint8Array | null`

TOTP multi-factor authentication secret.

\**otpAuthEnabled** `boolean`

Whether OTP authentication is enabled.

\**passkeyAuthEnabled** `boolean`

Whether passkey authentication is enabled.

Returns

\`Promise<void>`

Signature

\```typescript theme={null}
declare function update(data: ServerUserUpdateOptions): Promise<void>;
\```

Examples

\```typescript theme={null}
await serverUser.update({
  primaryEmail: "new@example.com",
  primaryEmailVerified: true,
});
\```

\</details>



\<details>

\<summary>`serverUser.setPrimaryEmail(email, [options])`
          
            
            serverUser</summary>

      

Sets the primary email for the user (server-side only).

Parameters

\**email** `string | null` *required*

The new primary email, or `null` to clear it.

\**options.verified** `boolean`

Whether to mark the email as verified.

Returns

\`Promise<void>`

Signature

\```typescript theme={null}
declare function setPrimaryEmail(
  email: string | null,
  options?: { verified?: boolean },
): Promise<void>;
\```

Examples

\```typescript theme={null}
await serverUser.setPrimaryEmail("new@example.com", { verified: true });
\```

\</details>



\<details>

\<summary>`serverUser.setServerMetadata(metadata)`
          
            
            serverUser</summary>

      

Sets the server metadata for the user.

Parameters

\**metadata** `Json` *required*

The new server metadata value.

Returns

\`Promise<void>`

Signature

\```typescript theme={null}
declare function setServerMetadata(metadata: any): Promise<void>;
\```

Examples

\```typescript theme={null}
await serverUser.setServerMetadata({ plan: "premium", internalId: "abc123" });
\```

\</details>



\<details>

\<summary>`serverUser.setClientReadOnlyMetadata(metadata)`
          
            
            serverUser</summary>

      

Sets the client read-only metadata that clients can read but not write.

Parameters

\**metadata** `Json` *required*

The new client read-only metadata value.

Returns

\`Promise<void>`

Signature

\```typescript theme={null}
declare function setClientReadOnlyMetadata(metadata: any): Promise<void>;
\```

Examples

\```typescript theme={null}
await serverUser.setClientReadOnlyMetadata({ role: "editor", tier: "pro" });
\```

\</details>



\<details>

\<summary>`serverUser.grantPermission(scope, permissionId)`
          
            
            serverUser</summary>

      

Server-side permission assignment.

Parameters

\**scope** `Team` *required*

The team scope.

\**permissionId** `string` *required*

The permission to grant.

Returns

\`Promise<void>`

Signature

\```typescript theme={null}
declare function grantPermission(scope: Team, permissionId: string): Promise<void>;
\```

Examples

\```typescript theme={null}
const team = await serverUser.getTeam("team_id_123");
if (team) {
  await serverUser.grantPermission(team, "my_permission_id");
}
\```

\</details>



\<details>

\<summary>`serverUser.revokePermission(scope, permissionId)`
          
            
            serverUser</summary>

      

Server-side permission removal.

Parameters

\**scope** `Team` *required*

The team scope.

\**permissionId** `string` *required*

The permission to revoke.

Returns

\`Promise<void>`

Signature

\```typescript theme={null}
declare function revokePermission(scope: Team, permissionId: string): Promise<void>;
\```

Examples

\```typescript theme={null}
const team = await serverUser.getTeam("team_id_123");
if (team) {
  await serverUser.revokePermission(team, "my_permission_id");
}
\```

\</details>



\<details>

\<summary>`serverUser.listContactChannels`
          
            
            serverUser</summary>

      

Returns server-specific contact channel details as `ServerContactChannel[]`.

Returns

\`Promise<ServerContactChannel[]>`

Signature

\```typescript theme={null}
declare function listContactChannels(): Promise<ServerContactChannel[]>;
\```

\</details>



\<details>

\<summary>`serverUser.listTeams([options])`
          
            
            serverUser</summary>

      

Lists the teams the user belongs to, as `ServerTeam` objects. Accepts the same options as [`CurrentUser.listTeams`](#currentuserlistteams): if `limit` is omitted, all teams are returned (and the request fails if the user is in more than 500 teams), and `nextCursor` is set when there are more teams than the requested `limit`.

Parameters

\**options.cursor** `string`

The `nextCursor` of the previous page. Requires `limit` to also be set.

\**options.limit** `number`

Maximum number of items to return per page, up to 200. Defaults to 200.

\**options.orderBy** `"createdAt"`

The field to sort results by.

\**options.desc** `boolean`

Whether to sort in descending order. Defaults to `false`.

\**options.query** `string`

Free-text search on the team's display name (and team ID if the query is a UUID).

Returns

\`Promise<ServerTeam[] & { nextCursor: string | null }>`

Signature

\```typescript theme={null}
declare function listTeams(options?: {
  cursor?: string;
  limit?: number;
  orderBy?: "createdAt";
  desc?: boolean;
  query?: string;
}): Promise<ServerTeam[] & { nextCursor: string | null }>;
\```

Examples

\```typescript theme={null}
const teams = await serverUser.listTeams({ limit: 20 });

if (teams.nextCursor) {
  const next = await serverUser.listTeams({
    cursor: teams.nextCursor,
    limit: 20,
  });
}
\```

\</details>



\<details>

\<summary>`serverUser.useTeams([options])`
          
            
            serverUser</summary>

      

React hook version of `listTeams`.

\> \\[!NOTE]
\>
\> This should be used on the server-side only.

Signature

\```typescript theme={null}
declare function useTeams(options?: {
  cursor?: string;
  limit?: number;
  orderBy?: "createdAt";
  desc?: boolean;
  query?: string;
}): ServerTeam[] & { nextCursor: string | null };
\```

\</details>



\<details>

\<summary>`serverUser.createSession([options])`
          
            
            serverUser</summary>

      

Creates a new session for the user. Can be used for impersonation.

Parameters

\**options.expiresInMillis** `number`

How long the session should last, in milliseconds.

\**options.isImpersonation** `boolean`

Whether this is an impersonation session.

Returns

\`Promise<{ getTokens(): Promise<{ accessToken: string | null; refreshToken: string | null }> }>`

Signature

\```typescript theme={null}
declare function createSession(options?: {
  expiresInMillis?: number;
  isImpersonation?: boolean;
}): Promise<{
  getTokens(): Promise<{
    accessToken: string | null;
    refreshToken: string | null;
  }>;
}>;
\```

Examples

\```typescript theme={null}
const session = await serverUser.createSession({
  expiresInMillis: 60 * 60 * 1000,
});
const tokens = await session.getTokens();
\```

\</details>



\<details>

\<summary>`serverUser.grantProduct(product)`
          
            
            serverUser</summary>

      

Grants a product to the user.

Parameters

\**product** `object` *required*

The product to grant. Either a `productId` or an inline product definition.

\**productId** `string`

The ID of an existing product to grant.

\**quantity** `number`

The quantity to grant.

Returns

\`Promise<void>`

Signature

\```typescript theme={null}
declare function grantProduct(
  product: { productId: string; quantity?: number } | { product: InlineProduct; quantity?: number },
): Promise<void>;
\```

Examples

\```typescript theme={null}
await serverUser.grantProduct({
  productId: "prod_premium",
  quantity: 1,
});
\```

\</details>

***# `CurrentServerUser`Combines all properties and methods from both `CurrentUser` and `ServerUser`, providing complete user access on the server side.## Table of ContentsCurrentServerUser Table of Contents<pre />> [!NOTE]
>
> React hook variants prefixed with `use` are available in React-like platforms
> and return unwrapped data rather than promises.
