Load the current backend user
A server route needs the complete Clerk profile for a known authenticated user.
Clerk · Module
Retrieves a Clerk User by ID through the backend SDK. It returns a promise resolving to the user's Backend User object.
Call this backend SDK method with a Clerk user ID to asynchronously retrieve that user's full Backend User object. The method returns a promise and wraps Clerk's Backend API request for the individual user resource.
function getUser(userId: string): Promise<User>| Name | Type | Description |
|---|---|---|
userId | string | The ID of the user to retrieve. |
Promise<User> resolving to the requested User object.
import { clerkClient } from '@clerk/express'
export async function getUserById(userId: string) {
return await clerkClient.users.getUser(userId)
}
Retrieves the Backend User object for the supplied Clerk user ID.
A server route needs the complete Clerk profile for a known authenticated user.
Backend code receives a Clerk user ID from trusted application context.
A server needs public metadata stored on the Clerk User resource.
users.getUser do?getUser() accepts a single string, userId, and returns a Promise<User>. It retrieves the user identified by that ID through Clerk's Backend API.
Follow-up: How would you retrieve the authenticated user's record? Obtain the authenticated userId from the server-side auth context, then pass it to clerkClient.users.getUser(userId).
userId parameter?The method requires a Clerk user ID, not an email address or another profile field. The returned User object contains the retrieved user's backend data.
Follow-up: What should be used for searching multiple users? Use the user-list method rather than calling getUser() repeatedly, because this method targets one known ID.
getUser() is a wrapper around the Backend API endpoint GET/users/{user_id}. Using the SDK avoids manually constructing that request while preserving the endpoint's single-user semantics.
Follow-up: What operational concern applies to repeated calls? Backend API rate limits apply, so frequently needed metadata may be better attached to the session token.
UserclerkClientusers.getUserList()currentUser()