getUser()
Loads the full backend user record for one user id. This returns the detailed
UserDetails shape rather than the smaller User objects used in list responses.Usage
The following example shows a basic usage of the backend client from @wacht/nextjs/server.
import { wachtClient } from '@wacht/nextjs/server';export async function getUser(userId: string) { const client = await wachtClient(); return client.users.getUser(userId);}Signature
function getUser( userId: string,): Promise<UserDetails>Parameters
›userId?: string | undefined;
userId?: string | undefined;Stable id of the user to load.
Return value
›id?: string | undefined;
id?: string | undefined;Stable user identifier.
›created_at?: string | undefined;
created_at?: string | undefined;Creation timestamp.
›updated_at?: string | undefined;
updated_at?: string | undefined;Last update timestamp.
›first_name?: string | undefined;
first_name?: string | undefined;Current first name.
›last_name?: string | undefined;
last_name?: string | undefined;Current last name.
›username?: string | undefined;
username?: string | undefined;Current username when one exists.
›profile_picture_url?: string | undefined;
profile_picture_url?: string | undefined;Current profile image URL.
›disabled?: boolean | undefined;
disabled?: boolean | undefined;Whether the user is currently disabled.
›public_metadata?: Record<string, unknown> | undefined;
public_metadata?: Record<string, unknown> | undefined;Public metadata stored on the user.
›tier?: string | undefined;
tier?: string | undefined;Example public tier/plan field.
›segment?: string | undefined;
segment?: string | undefined;Example public segment label.
›private_metadata?: Record<string, unknown> | undefined;
private_metadata?: Record<string, unknown> | undefined;Private metadata stored on the user.
›internal_notes?: string | undefined;
internal_notes?: string | undefined;Example internal note field.
›risk_score?: number | undefined;
risk_score?: number | undefined;Example internal risk score.
›primary_email_address?: string | undefined;
primary_email_address?: string | undefined;Primary email address string when one exists.
›primary_phone_number?: string | undefined;
primary_phone_number?: string | undefined;Primary phone number string when one exists.
›email_addresses?: UserEmail[] | undefined;
email_addresses?: UserEmail[] | undefined;Resolved email addresses attached to the user.
›phone_numbers?: UserPhone[] | undefined;
phone_numbers?: UserPhone[] | undefined;Resolved phone numbers attached to the user.
›social_connections?: UserSocialConnection[] | undefined;
social_connections?: UserSocialConnection[] | undefined;Linked social connections attached to the user.
›segments?: Segment[] | undefined;
segments?: Segment[] | undefined;Segments currently attached to the user.
›has_password?: boolean | undefined;
has_password?: boolean | undefined;Whether the user currently has a password set.
›has_backup_codes?: boolean | undefined;
has_backup_codes?: boolean | undefined;Whether the user currently has backup codes generated.
What it returns
This method loads the detailed backend user payload, not the lighter list-item shape returned by
listUsers().That makes it the right read operation when your admin flow needs metadata, contact inventories, social connections, password state, or segment assignments for one user.
Examples
Load one user for an admin page
import { wachtClient } from '@wacht/nextjs/server';export async function getUser(userId: string) { const client = await wachtClient(); return client.users.getUser(userId);}Read profile and metadata fields
import { wachtClient } from '@wacht/nextjs/server';export async function getUserAdminSummary(userId: string) { const client = await wachtClient(); const user = await client.users.getUser(userId); return { id: user.id, fullName: [user.first_name, user.last_name].join(' '), disabled: user.disabled, publicMetadata: user.public_metadata, };}