Client object
The Client object keeps track of the authenticated sessions in the current device. The device can be a browser, a native application, or any other medium that is usually the requesting part in a request/response architecture.
The Client object also holds information about any sign-in or sign-up attempts that might be in progress, tracking the sign-in or sign-up progress.
Example
The Client object is available on the Clerk object. Use the useClerk() hook to access the clerk object, as shown in the following example.
import { useClerk } from '@clerk/expo'
import { Text, View } from 'react-native'
export default function Page() {
// Use the useClerk hook to access the clerk object
const clerk = useClerk()
// Access the client object
const client = clerk.client
return (
<View>
<Text style={{ whiteSpace: 'pre' }}>{JSON.stringify(client, null, 2)}</Text>
</View>
)
}- Name
captchaBypass- Type
boolean- Description
Indicates if CAPTCHA checks are skipped for this client.
- Name
cookieExpiresAt- Type
Date | null- Description
The date and time when the client's authentication cookie expires.
- Name
createdAt- Type
Date | null- Description
The date when the client was first created.
- Name
lastActiveSessionId- Type
string | null- Description
The ID of the last active Session on this client.
- Name
lastAuthenticationStrategy- Type
LastAuthenticationStrategy | null- Description
The last authentication strategy used by the client, or
nullif there is none.
- Name
sessions- Type
- Session[]
- Description
A list of sessions that have been created on this client.
- Name
signedInSessions- Type
- SignedInSessionResource[]
- Description
A list of sessions on this client where the user has completed the full sign-in flow. Sessions can be in one of the following states:
- active: The user has completed the full sign-in flow and all pending tasks.
- pending: The user has completed the sign-in flow but still needs to complete one or more required steps (pending tasks).
- Name
signIn- Type
SignIn | null- Description
The current sign in attempt, or
nullif there is none.
- Name
signInAttempt- Type
SignIn | null- Description
Alias for the
signInproperty. The current sign in attempt, ornullif there is none.
- Name
signUp- Type
SignUp | null- Description
The current sign up attempt, or
nullif there is none.
- Name
signUpAttempt- Type
SignUp | null- Description
Alias for the
signUpproperty. The current sign up attempt, ornullif there is none.
- Name
updatedAt- Type
Date | null- Description
The date when the client was last updated.
Methods
isNew()
Returns true if this client hasn't been saved (created) yet in the Frontend API. Returns false otherwise.
function isNew(): booleancreate()
Creates a new client for the current instance along with its cookie.
function create(): Promise<Client>fetch()
Fetches the latest client data from the Frontend API. Optionally accepts a number of retries for the request.
function fetch(params?: { fetchMaxTries?: number }): Promise<Client>destroy()
Deletes the client. All sessions will be reset.
function destroy(): Promise<void>removeSessions()
Removes all sessions created on the client.
function removeSessions(): Promise<Client>resetSignIn()
Resets the current sign-in attempt. Clears the in-progress sign-in state on the client.
function resetSignIn(): voidresetSignUp()
Resets the current sign-up attempt. Clears the in-progress sign-up state on the client.
function resetSignUp(): voidclearCache()
Clears any locally cached session data for the current client.
function clearCache(): voidisEligibleForTouch()
Returns true if the client cookie is due to expire in 8 days or less. Returns false otherwise.
function isEligibleForTouch(): booleanbuildTouchUrl()
Builds a URL that refreshes the current client's authentication state and then redirects the user to the specified URL.
function buildTouchUrl(params: { redirectUrl: URL }): stringFeedback
Last updated on