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.

Example

The Client object is available on the Clerk object. Use the useClerk() composable to access the clerk object, as shown in the following example.

ClientStatus.vue
<script setup>
import { useClerk } from '@clerk/vue'

// Use the useClerk composable to access the clerk object
const clerk = useClerk()

// Access the client object
const client = clerk.client
</script>

<template>
  <pre>{JSON.stringify(client, null, 2)}</pre>
</template>
  • 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 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
    signInAttempt
    Type
    SignIn | null
    Description

    Alias for the signIn property. 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
    signUpAttempt
    Type
    SignUp | null
    Description

    Alias for the signUp property. 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

create()

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(): void

resetSignUp()

Resets the current sign-up attempt. Clears the in-progress sign-up state on the client.

function resetSignUp(): void

clearCache()

Clears any locally cached session data for the current client.

function clearCache(): void

isEligibleForTouch()

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

function isEligibleForTouch(): boolean

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

Feedback

What did you think of this content?

Last updated on