Skip to main content
Docs

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.

Properties

  • Name
    captchaBypass
    Type
    boolean
    Description

    A boolean that 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 null if 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 null if there is none.

  • Name
    signUp
    Type
    SignUp | null
    Description

    The current sign up attempt, or null if 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(): boolean
clerk.client.isNew()

create()

Creates a new client for the current instance along with its cookie.

function create(): Promise<Client>
await clerk.client.create()

destroy()

Deletes the client. All sessions will be reset.

function destroy(): Promise<void>
await clerk.client.destroy()

removeSessions()

Removes all sessions created on the client.

function removeSessions(): Promise<Client>
await clerk.client.removeSessions()

clearCache()

Clears any locally cached session data for the current client.

function clearCache(): void
clerk.client.clearCache()

isEligibleForTouch()

Returns true if the client cookie is due to expire in 8 days or less. Returns false otherwise.

function isEligibleForTouch(): boolean
clerk.client.isEligibleForTouch()

buildTouchUrl()

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 }): string
const url = new URL('/dashboard', window.location.origin)

clerk.client.buildTouchUrl({ redirectUrl: url })

Feedback

What did you think of this content?

Last updated on