Type user values
Typing functions, component props, or state that receive a Clerk user.
Clerk · Interface
UserResource is Clerk’s type for a user object used in application code. Import it through the SDK’s public types entry point to add type safety to user data and operations.
UserResource is Clerk’s typed representation of one user. Import it from the SDK’s public types entry point, then use it to type values containing user data and account-management capabilities exposed by Clerk.
import type { UserResource } from '@clerk/shared/types'A type describing a Clerk user resource; it is not a runtime-returning function.
import type { UserResource } from '@clerk/shared/types'
export function displayName(user: UserResource): string {
return user.fullName ?? user.primaryEmailAddress?.emailAddress ?? user.id
}This type-only import lets TypeScript validate code that reads a Clerk user resource without adding a runtime import.
Typing functions, component props, or state that receive a Clerk user.
Reading user properties with editor completion and compile-time checks.
Sharing a stable user type across application modules without runtime imports.
UserResource is a Clerk type describing the current user object and its user-management data. In the JavaScript documentation, it is imported from @clerk/shared/types with a type-only import.
Follow-up: Why use a type-only import? It preserves compile-time checking while avoiding a runtime module import for a type.
First install @clerk/shared, then import UserResource from the package’s /types entry point. The import is written with TypeScript’s type-only syntax.
Follow-up: How would you adapt the import for a framework SDK? Use that SDK’s public /types entry point, such as the React SDK’s /types entry point.
A UserResource value can be used to type code that works with a Clerk user, including user data and account-management operations. It is a type rather than a runtime object constructor.
Follow-up: How can an application obtain a current UserResource? Use the framework’s user-access API, such as a documented useUser hook, whose user value is typed as UserResource.
useUser()User@clerk/shared/types