Clerk logo

Clerk Docs

Ctrl + K
Go to clerk.dev

Client

The Client object tracks sessions, as well as the state of any sign in and sign up attempts.

Overview

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.

Attributes

NameTypeDescription
signInSignInResource | null

The current sign in attempt, or null if there is none.

signUpsignUpResource ​ | null

The current sign up attempt, or null if there is none.

sessionsSession[]

A list of sessions that have been created on this client.

activeSessionsSession[]

A list of active sessions on this client.

lastActiveSessiondstring

Unique identifier of the last active Session on this client.

updatedAt Date

Timestamp of last update for the client.

Methods

create()

create() => Promise<ClientResource>

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

Parameters
This method accepts no parameters.

Returns

TypeDescription
Promise<ClientResource>

This method returns a Promise which resolves with a Client object.

destroy()

destroy() => Promise<void>

Deletes the client. All sessions will be reset.

Parameters
This method accepts no parameters.

Returns

TypeDescription
Promise<void>

This method returns a Promise which doesn't resolve to any value.

isNew()

isNew() => boolean

Returns true if this client hasn't been saved (created) yet in the Frontend API, false otherwise.

Parameters
This method accepts no parameters.

Returns
This method returns true for new clients, false otherwise.

Was this helpful?

Clerk © 2022