Clerk

The Clerk object is a singleton that is used to access the Client object, and to track which session and user are active.

Attributes

Name

Description

client

Client

The Client object for the current window.

user

User | null | undefined

A shortcut to session.user which holds the currently active User object. If session is null or undefined, this field will match.

session

Session | null | undefined

The currently active Session, which is guaranteed to be one of the Session's in client.sessions. If there is no active Session, this field will be null. If the Session is loading, this field will be undefined.

Functions

closeSignIn

Arguments
Return
Arguments

No arguments.

Return

No return value.

Closes the SignIn modal.

closeSignUp

Arguments
Return
Arguments

No arguments.

Return

No return value.

Closes the SignUp modal.

openSignIn

Arguments
Return
Arguments

No arguments.

Return

No return value.

Opens the SignIn modal.

openSignUp

Arguments
Return
Arguments

No arguments.

Return

No return value.

Opens the SignUp modal.

setSession

Arguments
Return
Arguments

Name

Description

session

Session | string | null

A Session object or Session ID string to be set as this.session, or null to remove the active session.

beforeEmit?

(session: Session | null) => Promise<any> | void

Usually used for navigation — the passed function will run while this.session is set to undefined, before finally being set to the passed session.

Return

Returns a promise that resolves after after passed session is set. The promise does not resolve a value.

Change this.session to the passed session. The change happens in three steps:

  1. this.session is set to undefined, which causes the control components to stop rendering their children as though Clerk is still initializing.

  2. beforeEmit is run. If a promise is returned, Clerk waits for the promise to resolve.

  3. this.session is set to the passed session. This causes the control components to render their children again.