Skip to content
masterclassBuddyTech Buzz5 fresh blogs · 5:00 AM IST

Clerk · Class

Session

Clerk's Session object represents the current user's authenticated interaction with the server. It is accessed through Clerk and supports inspecting session state, refreshing activity, clearing cached data, and ending the session.

How it works

The Session object represents the authenticated exchange between a user and Clerk's server. Clerk creates one when the user signs in, exposes it through the Clerk object, and lets the client inspect activity, clear stale cached data, or end the session.

Syntax

const session = clerk.session
await session.end()

Returns

The Session object exposes session state and lifecycle methods; remove() and touch() return Promise<SessionResource>.

Key points

  • Session carries the current user's authenticated state in a secure representation.
  • In the SDK, this state is exposed through a Session object.
  • One client may maintain multiple sessions on the same device.
  • Its API covers activity recording as well as client-side termination.
  • Signing in automatically creates a session for the client.
  • Access the session through the Clerk instance.
  • clearCache() is useful when session changes make cached data stale.
  • end() marks the current session as ended.

Common mistakes

  • A client may have several sessions, but only one is active at a time.
  • Ending or losing a client-side session is not the only lifecycle event; the server can expire sessions too.
  • Calling end() makes the session inactive for the current client.

Example: Read and end the active session

import { Clerk } from '@clerk/clerk-js'

const clerk = new Clerk(import.meta.env.VITE_CLERK_PUBLISHABLE_KEY)
await clerk.load()

const session = clerk.session
if (session) {
  console.log(session.status)
  await session.end()
}

Loads Clerk, reads the currently active session, logs its status, and ends it when present.

When to use it

Read authentication state

After Clerk loads, inspect whether the client has an active authenticated session.

Clear stale session cache

When session-related data has changed, invalidate locally cached session information.

End a client session

When the user signs out or the application must terminate the current client session, call end().

Interview questions

QWhat does Clerk's Session object represent?

A Session models the period of information exchange between a user and Clerk's server. Clerk creates it when the user signs in, and it is available from the Clerk object.

Follow-up: Can multiple sessions exist? Yes. A client can hold multiple sessions, but only one can be active at any given time.

QHow do you access the active session?

Use clerk.session after loading Clerk to access the current session. The value represents the active session for the client when one exists.

Follow-up: What if no session is active? Treat the value as absent and avoid calling session methods until a session is available.

QHow do you end a session?

session.end() marks the session as ended for the current client and changes its status to ended. It is the client-side operation for ending that session.

Follow-up: Does this prevent every possible session termination path? No. Clerk can also expire sessions on the server for security reasons.

  • Clerk
  • Client
  • User
  • SessionVerification
  • SessionResource
  • clearCache()
  • end()
  • touch()

Source: Session object - Objects - JavaScript. Checked 2026-10-15.