Skip to Content
Clerk logo

Clerk Docs

Ctrl + K
Go to clerkstage.dev

getCount()

Retrieves the total number of users.

const totalUsers = await clerkClient.users.getCount();

This can also be flitered down by adding parameters of the type UserCountParams.

UserCountParams

NameTypeDescription
emailAddress?string[]The email addresses to filter by.
phoneNumber?string[]The phone numbers to filter by.
username?string[]The usernames to filter by.
web3wallet?string[]The web3wallet to filter by.
query?stringA search query to filter users by.
userId?stringThe user ID's to filter by.
externalId?string[]The external ID's to filter by.

Example

getCount({ query })

To do a broader match through a list of fields, you can use the query parameter which partially matches the fields: userId, emailAddress, phoneNumber, username, web3Wallet, and externalId.

This example retrieves the total number of users matching the query test.

const totalUsersMatchingTest = await clerkClient.users.getCount({ query: 'test' })

What did you think of this content?

Clerk © 2023